import itertools a = [[1, 2], [3, 4], [5, 6]] list(itertools.chain.from_iterable(a)) Output:- [1, 2, 3, 4, 5, 6]
Here is what the above code is Doing:
1. itertools.chain.from_iterable(a)
2. itertools.chain(a[0], a[1], a[2])
3. itertools.chain([1, 2], [3, 4], [5, 6])
4. [1, 2, 3, 4, 5, 6]