Learn Before
Code

Lambdas in Python

Lambdas are shorthand function definitions. A lambda function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression. The syntax is, lambda arguments : expression. For instance,

func = lambda x, y : x + y

defines a Python function that takes two arguments (which must support the + operator) and returns their sum/concatenation.

0

4

Updated 2021-02-02

Tags

Data Science