Flatten a Nested List in Python Using in-build Sum() Function

(Last Updated On: 20/01/2023)

Python Program to Flatten a Nested List Using in-build Sum() Function

#Flatten a Nested List in python Using In-build sum() function

list = [[11, 22, 33, 44], [55, 66, 77], [88, 99]]

#we are using a python In-build sum() function
flatList = sum(list, [])
  
# Output
print('New list', flatList)

Output:

New list [11, 22, 33, 44, 55, 66, 77, 88, 99]

Leave a Reply

Your email address will not be published. Required fields are marked *