Answers for "list comprehension python not double"

3

python list comprehension double for

[x for y in collection for x in y] # [A for B in C for D in E]
Posted by: Guest on January-02-2021
1

python list comprehension double for

>>> l = [(x,y) for x in range(0,3) for y in range(5, 8)]
>>> l
[(0, 5), (0, 6), (0, 7), (1, 5), (1, 6), (1, 7), (2, 5), (2, 6), (2, 7)]

# they can also be "chained"
>>> l = [(x,y) for x in range(0,4) for y in range(0, x)]
>>> l
[(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)]
Posted by: Guest on May-21-2021

Code answers related to "list comprehension python not double"

Python Answers by Framework

Browse Popular Code Answers by Language