How to merge multiple lists into one list in python? [duplicate]
Possible Duplicate:
Making a flat list out of list of lists in Python
Join a list of lists together into one list in Python
I have many lists which looks like
['it']
['was']
['annoying']
I want the above to look like
['it', 'was', 'annoying']
How do I achieve that?
import itertools
ab = itertools.chain(['it'], ['was'], ['annoying'])
list(ab)
Just another method....
Just add them:
['it'] + ['was'] + ['annoying']
You should read the Python tutorial to learn basic info like this.
a = ['it']
b = ['was']
c = ['annoying']
a.extend(b)
a.extend(c)
# a now equals ['it', 'was', 'annoying']