Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to Flatten a nested list in python

import itertools

a=[[1, 2, 3], [4, 5, 6]]

flat_list = list(itertools.chain.from_iterable(a))
print(flat_list)

# Output:
[1, 2, 3, 4, 5, 6]
 
PREVIOUS NEXT
Tagged: #How #Flatten #nested #list #python
ADD COMMENT
Topic
Name
1+8 =