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


Picture showing the output of the Map function in python



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, March 12, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250