1# idiomatic python
2
3# using itertools
4import itertools
5
6list_of_list = [[1, 2, 3], [4, 5], [6]]
7chain = itertools.chain(*images)
8
9flattened_list = list(chain)
10# [1, 2, 3, 4, 5, 6]
1from collections.abc import Iterable
2
3def flatten(l):
4 for el in l:
5 if isinstance(el, Iterable) and not isinstance(el, (str, bytes)):
6 yield from flatten(el)
7 else:
8 yield el
9