Posted on 16th September 2024| views
You can understand it by this example
list_of_lists = [[5, 6], [7, 8]]
chain_object = itertools.chain.from_iterable(list_of_lists)
flattened_li = list(chain_object)
Convert to list to flatten
print(flattened_li)
Output: [5, 6, 7, 8]