Mega Code Archive

 
Categories / Python Tutorial / Function
 

A lambda function squares the members of a sequence

print map(lambda x: x ** 2, range(6)) # list comprehension statement: print [x ** 2 for x in range(6)]