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






Define a function to construct list

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

1.List comprehensions: for and tupleList comprehensions: for and tuple
2.List comprehensions: map and tupleList comprehensions: map and tuple
3.List Comprehensions: a concise way to create lists
4.Find Prime numbers using listFind Prime numbers using list
5.List Comprehensions in buildConnectionString, Step by StepList Comprehensions in buildConnectionString, Step by Step