
Python | map() Function
The map() function executes a specified function for each item in an iterable. The map() function in Python has two parameters, function and iterable. The map() function takes a function as an argument and then applies that function to all the elements of an iterable, passed to it as another argument. It returns an object list of results.
def myfun(n):
return len(n)
x = map(myfun, ('apple', 'banana', 'cherry'))
print(x)
# <map object at 0x056D44F0>
print(list(x))
# [5, 6, 6]