Python Program to Flatten a Nested List in Python Using Lambda and Reduce()
#Flatten a Nested List in Python Using Lambda and Reduce() Function from functools import reduce my_list = [[1], [2, 3], [4, 5, 6, 7], [8, 9, 10, 11]] # Output reduce() applies the lambda function to all the elements of my_list print(reduce(lambda x, y: x+y, my_list))
Output:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]