Lambda Function#


A lambda function is known as an anonymous function, and is a concise way to create a function without def statement. The lambda functions were proposed to generate a direct, one line operations, and are defined using the lambda keyword

General syntax

my_function = lambda arguments: expression


multiply = lambda x, y: x * y
result = multiply(5, 3)
print(result)  # Output: 15

Lambda with argument#

Lambda function can also accept arguments:

# lambda that accepts one argument
student_user = lambda major : print('My major is ', major)

# lambda call
My major is  ABE