How to create a flat list out of list of lists in Python

1 Answer

0 votes
lst = [[1, 2, 3], [4, 5, 6, 7], [8], [0, 12]]

f_list = [item for sublist in lst for item in sublist]

print(f_list)



'''
run:

[1, 2, 3, 4, 5, 6, 7, 8, 0, 12]
 
'''

 



answered Jul 23, 2019 by avibootz
...