Top

Nested list comprehension syntax in Python

Aug 05, 2020 | 707 views

#Python


Refer to 


Example: 

>>> non_flat = [ [1,2,3], [4,5,6], [7,8] ]
>>> [y for x in non_flat for y in x]
[1, 2, 3, 4, 5, 6, 7, 8]


Leave a comment

0 comments