Published Apr 23, 2022Updated Jul 11, 2022
Contribute to Docs
lambda keyword produces anonymous function expressions without using the
def keyword. Lambda expressions are commonly used for defining single-use functions which are then passed to higher-order functions.
lambda parameter_list : expression
parameter_list is provided and mapped into the
expression on the other side of the colon
lambda expression can be assigned to a variable like in the example below:
example = lambda base, exponent : base**exponentprint(example(2, 3))
Below is another example of using a
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification