🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Python Beginner

What is Lambda Function?

An anonymous, single-expression function defined inline using the lambda keyword.

Lambda functions are small anonymous functions defined with the lambda keyword: lambda arguments: expression. They can have any number of arguments but only one expression.

Common uses include sorting keys (sorted(data, key=lambda x: x[1])), filtering (filter(lambda x: x > 0, numbers)), and callback functions. For complex logic, named functions are preferred.