🧭Lambda Function
Also known as Lambda, Anonymous Function, Arrow Function
A small function in one line, often with no name. You use it once.
Think of it like
Think of it like a sticky note with one quick job on it. You use it once and throw it away.
Example
Jack sorts a list of players by score with a lambda. The whole rule for sorting fits inside the sort call.
Why it matters
Lambdas keep a tiny rule right where it is used. You do not need to jump elsewhere to read it.
Definition
Example code
python
>>> square = lambda x: x * x
>>> square(4)
16Common mistake
Key takeaways
- 1One line. A short piece of code.
- 2Often nameless. Used in one place.
- 3Arrow or lambda. Same idea, two spellings.