itertools.chain
itertools.chain() links multiple iterables end-to-end without creating a new list.
itertools.chain() links multiple iterables end-to-end without creating a new list.
from itertools import chain
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8, 9]
for val in chain(a, b, c):
print(val, end=" ")
# 1 2 3 4 5 6 7 8 9
chain.from_iterable() is useful when you have a list of lists to flatten.