What is anonymous function or lambda function in python?


To see what is lambda function and syntax of lambda function in python3.

Anonymous or lambda function.

   Lambda functions are small functions usually not more than a line.

   Its also called as one line function.

   Lambda function can have any number of arguments but only one expression.

   It defined with keyword lambda.

   Its mostly used for mathematical expression

#lambda function to double the input
d = lambda x: x * 2
print(“——First output——\n”)

#lambda functions with mapping
print(“——Second output——\n”)
newlist=list(map(lambda x: x * 2,list1))

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit