Nested list comprehension syntax in Python
Aug 05, 2020 | 707 views
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]
Aug 05, 2020 | 707 views
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]