Python Lambda Function
python lambda function is similar to def keyword where def keyword is used to define a normal function in python and lambda keyword is used to define an anonymous function in python.
- Lambda function is used whenever function objects are required.
- Lambda functions are syntactically restricted to single expression.
- It is mainly used in programming .
Lambda function syntax :
Syntax : lambda arguments : expression
EXAMPLE:
str = 'NeethikaChiliveri' upper = lambda string: string.upper print(upper(str))
OUTPUT : NEETHIKACHILIVERI
Here the lambda function upper() is used to convert them to uppercase
USE of Lambda function:
we use lambda function as an argument to a higher-order function
filter(),map(), and reduce() are used together with built-in-functions