ReferenceBuilt-in functions
map()
Applies a function to every item.
Signature
map(function, iterable)Parameters
| Name | Means |
|---|---|
function | called once per item |
iterable | one or more sequences |
Returns
An iterator, used up after one pass.
Example
Python
print(list(map(str.upper, ["a", "b"])))
print(list(map(lambda n: n * n, [1, 2, 3])))
print(list(map(int, ["1", "2"])))Output
['A', 'B'] [1, 4, 9] [1, 2]