Python map() FunctionThe 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.) SignatureParametersfunction- 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. ReturnIt returns a list of results after applying a given function to each item of an iterable(list, tuple etc.) Python map() Function Example 1The 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 2The below example shows how to use lambda function with map(). Output: <map 0x7f53009e7cf8> {0}
Next TopicPython Functions
|