What is lambda function in Python

Lambda function in Python is an anonymous function , it means simply a functions that don’t have a name.In normal function we are def keywords to define a functions, but in Lambda functions we always defined by the keyword Lambda.Lambda as any number of argument but only a single expression.It is generally using for a short term usage situations.

Syntax of Python Lambda Function

lambda arguments: expression
e.g

division = lambda x: x / 2

Normal functions that equal above lambda functions

def division(x):
   return x / 2
# Program to filter out only the odd number from a list
my_number = [1, 12, 6, 11, 7, 17, 23, 14]

new_odd = list(filter(lambda x: (x%2 == 1) , my_number))

print(new_odd )

Lambda function in Python

what is the usage of python lambda functions

My Thought

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

Our Tool : hike percentage calculator