Python lambda keyword

Create a function that will send any number of plus 10:

x = lambda a : a + 10

print(x(5))
  1. lambda keyword is used to create a small anonymous functions.

  2. Lambda function can accept any number of arguments, but only has one expression.

  3. This expression is evaluated and returns the result.

lambda functions with three parameters:

x = lambda a, b, c : a + b + c

print(x(5, 6, 2))
Published 186 original articles · won praise 21 · views 10000 +

Guess you like

Origin blog.csdn.net/sinat_23971513/article/details/105290085