What is lambda in Python?


Lambda creates simple anonymous function. It is simple because it can only have one statement in its body. It is anonymous because usually it does not have a name.
The usual use is as we saw earlier when we passed it as a parameter to the map function. However, in the next example we show that you can assign the lambda-function to a name and then you could used that name just as any other function you would define using def.

examples/functional/lambda.py
def dbl(n):
    return 2*n
print(dbl(3))

double = lambda n: 2*n
print(double(3))

6
6