# Lambda Function

*noun*

say it: **“LAM-duh FUNGK-shun”** **/ˈlæmdə ˈfʌŋkʃən/**

A small, nameless function written in one line, such as lambda person: person\[1\], mostly used where a function is needed once.

## What is a **lambda function**?

A **lambda function** is a small, nameless function written in one line. It's mostly used where a function is needed just once, like telling `sorted()` what to sort by.

```python
people = [("Ana", 31), ("Ben", 25)]
by_age = sorted(people, key=lambda person: person[1])
print(by_age)  # [('Ben', 25), ('Ana', 31)]
```

## In a sentence

- “The **lambda** picks the price out of each tuple.”
- “sorted() used a **lambda function** to sort people by age.”

Level: Journeyman · [More Python terms at this level](https://www.ask-codey.com/glossary?category=python&level=3)

Updated: November 19, 2026

Source: https://www.ask-codey.com/glossary/lambda-function
