The map() function returns map object after applying a given function to each item of an iterable (list, tuple etc.) .
Syntax:
map(function, iterables)
Parameters:
- function : It is a function to which map passes each element of given iterable.
- iterables : It is used to map.
Return Values:
It return value from map()
(map object) after applying the given function to each item of a given iterable (list, tuple etc.).
Example:
def power(n):
return n ** 2
num = (1,2,3,4,5,6)
res = (map(power,num))
print(list(res))
Output: [1, 4, 9, 16, 25, 36]
- Log in to post comments