Define a function to construct list : List Comprehensive « List « Python
- Python
- List
- List Comprehensive
Define a function to construct list

S = [x**2 for x in range(10)]
V = [2**i for i in range(13)]
M = [x for x in S if x % 2 == 0]
print S; print V; print M
Related examples in the same category