The map Functionmap(func, s) applies a function to each element of a sequence
a = [1,2,3,4,5,6]
def foo(x):
return 3*x
b = map(foo,a) # b = [3,6,9,12,15,18]
b = map(lambda x: 3*x, a) # b = [3,6,9,12,15,18] Special cases
|
| <<< | O'Reilly OSCON 2000, Introduction to Python, Slide 86 July 17, 2000, beazley@cs.uchicago.edu |
>>> |