Given input:
list = [['a']['a', 'c']['d']]
Expected Ouput:
mylist = a,c,d
Tried various possible ways, but the error recieved is TypeError: list indices must be integers not tuple.
Tried:
1.
k= []
list = [['a']['a', 'c']['d']]
#k=str(list)
for item in list:
k+=item
print k
2.
print zip(*list)
etc.
Also to strip the opening and closing parenthesis.
What you want is flattening a list.
Edit: And your problem is, when defining a list, you should seperate values with a comma. So, not:
Use commas:
And also, using
listas a variable is a bad idea, it conflicts with builtinlisttype.And, if you want to use a for loop:
But using itertools.chain is better idea and more pythonic I think.