Lambda Expressions in Python

By Hemanta Sundaray on 2021-08-18

In Python, lambda expressions are used to create anonymous functions expressed as a single statement.

Syntax

lambda parameters : expression

A lambda has zero or more comma separated arguments followed by a colon and then the definition of the function.

The body of a lambda function can only be pure expressions. (An expression always resolves to a value.)

Example:

add = lambda a, b : a * b

print(add(10, 10))
# 100

lambda a, b : a * b returns the multiplication of its two arguments: a & b.

Join the Newsletter