midPython
Lambda Functions
Updated May 4, 2026
Short answer
Anonymous, one-line functions.
Deep explanation
Short functions defined without a name, used where a full function definition is overkill (e.g., sorting).
Real-world example
Sorting a list of user tuples by their age.
Common mistakes
- Using lambda for complex logic that should be a proper 'def' function.
Follow-up questions
- Can lambdas have multiple lines?