113
Python map() Function
The python map() function is used to return a list of results after applying a given function to each item of an iterable(list, tuple etc.)
Signature
Parameters
function– It is a function in which a map passes each item of the iterable.
iterables– It is a sequence, collection or an iterator object which is to be mapped.
Return
It returns a list of results after applying a given function to each item of an iterable(list, tuple etc.)
Python map() Function Example 1
The below example shows the working of map().
Output:
<map object at 0x7fb04a6bec18> {8, 2, 4, 6}
Explanation: In this example, it returns the list of results after applying a given function to each item of an iterable.
Python map() Function Example 2
The below example shows how to use lambda function with map().
Output:
<map 0x7f53009e7cf8> {0}
Next TopicPython Functions