def flatten(t):
return [item for sublist in t for item in sublist]
>>> import itertools
>>> list2d = [[1,2,3], [4,5,6], [7], [8,9]]
>>> merged = list(itertools.chain(*list2d))
merged = list(itertools.chain.from_iterable(list2d))
# Given a list of lists l,
flat_list = [item for sublist in l for item in sublist]
>>> import itertools
>>> list2d = [[1,2,3], [4,5,6], [7], [8,9]]
>>> merged = list(itertools.chain.from_iterable(list2d))