For any queries you can reach us at infovistarindia@gmail.com / WhatsApp us: +919158876092

Lambda function in Python

Lambda Functions

A lambda function is a anonymous function in Python.

In pythton, a normal functions are defined using the def keyword, anonymous functions are defined using the lambda keyword.

In pythton, a lambda function can take number of arguments, but can only have one expression.

Syntax of Lambda Function

lambda arguments: expression

The expression is executed and the result is returned.

Example

lambda_add = lambda a, b: a + b
				    
print(add_lambda(20,20))

In the above program, lambda a, b: a + b is the lambda function. Here a, b is the argument and a + b is the expression that gets evaluated and returned.