lambda
A short one-line function.
Syntax
name = lambda p: expression
Description
A small, anonymous, single-expression function. Usually passed as an argument to places like sort/map/filter.
Example
Loading editor…
Expected output
36 [3, 2, 1]
When to use?
A sort key, short transformations; for bigger logic, prefer a normal def.