Lambda function in Python
A lambda function in Python is a small anonymous function that begins with the lambda keyword followed by a comma-separated parameter list, a colon (:) and an expression.
Get Hadi’s stories in your inbox
Join Medium for free to get updates from this writer.
A lambda implicitly returns its expression’s value. So any simple function of the form
def function_name(parameter_list):
return expressionmay be expressed as a more concise lambda of the form
lambda parameter_list: expressionFor example, consider the following lambda function:
multiply = lambda x, y: x * y
result = multiply(3, 4)
print(result) # Output: 12This lambda function takes two arguments x and y and returns their product. We can call this lambda function like any other function.





