Articles → Python → Map Function In Python
Map Function In Python
Purpose
Example
#A list where a function needs to be applied
mylist = [1,2,3,4,5]
# Takes an input variable and returns the double value of the input parameter
def MyFunction(var):
return var*2
# Calling a map function and applying the function
print(list(map(MyFunction, mylist)))
Output