If you have a list of lists like this:
lol = [[1, 2, 3], [4, 5], [6, 7, 8, 9]]
And you want to flatten it into a single list like this:
[1, 2, 3, 4, 5, 6, 7, 8, 9]
You can use a list comprehension like this:
l = [item for sublist in lol for item in sublist]
Or you can use itertools.chain()
like this:
from itertools import chain l = list(chain(*lol))