A lambda expression in Python is used for creating an anonymous function.
Wherever we need a function, we can also use a lambda expression.
We have to use lambda keyword for creating a lambda expression.
Syntax of lambda function is as follows:
lambda argumentList: expression
E.g.
>>>lambda a,b: a+b
The above mentioned lambda expression takes two arguments and returns their sum.
We can use lambda expression to return a function.
A lambda expression can be used to pass a function as an argument in another function.
Leave a Reply