Definition
The map() function executes a specified function for each item in an iterable. The item is sent to the function as a parameter.
Syntax
map(function, iterables)
Parameters
Parameter | Description |
---|---|
function | Required. The function to execute for each item |
iterables | Required. A sequence, collection or an iterator object. You can send as many iterables as you like, just make sure the function has one parameter for each iterable. |
Examples
def myFunction(x):
return len(x)
result = map(myFunction, ('apple', 'banana', 'cherry'))
print(result)