Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

flatten list in python

regular_list = [[1, 2, 3, 4], [5, 6, 7], [8, 9]]
flat_list = [item for sublist in regular_list for item in sublist]
print('Original list', regular_list)
print('Transformed list', flat_list)
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #flatten #list #python
ADD COMMENT
Topic
Name
9+3 =