Reputation: 323
I have this code:
def write_extension(self):
extension = []
dtd = ""
if extension == []:
extension = extension.extend(self.edids[] (Thanks to Howardyan for making it clearer for me)
print(extension)
I want to write the complete array in the new array extension
but i dont know how. Is there an easy way doing this? Later on (when extension
is not empty) i just want to add the array to the end of the extension
array.
To Make it clear. Now i have this:
And i want to have this after i added all arrays to extension
extension = [123, 456, 789]
Upvotes: -1
Views: 1320
Reputation: 3562
You can join all the elements in your individual lists, and then extend from extension like so:
name1 = [1, 2, 3]
name2 = [4, 5, 6]
name3 = [7, 8, 9]
extension = []
''.join(map(str, name1))
''.join(map(str, name2))
''.join(map(str, name3))
extension.extend((name1, name2, name3))
>>> [123, 456, 789]
Upvotes: 1
Reputation: 657
extension's type is str. cannot add with a list. you need do this:
def write_extension(self):
extension = []
dtd = ""
if extension == []:
extension = extension.extend(self.edids[:])
print(extension)
Upvotes: 1