Python Program to Flatten a Nested List (Using sum())

bookmark

my_list = [[1], [2, 3], [4, 5, 6, 7]]

flat_list = sum(my_list, [])
print(flat_list)

 

Output

[1, 2, 3, 4, 5, 6, 7]