# deque

say it: **“DEK”** **/dɛk/**

A list built for quickly adding and removing at both ends.

## What is a `deque`?

A `deque` (say "deck") is a list built for adding and removing at both ends quickly, perfect for queues and "last N items" lists.

```python
from collections import deque

recent = deque(maxlen=3)          # keeps only the last 3
for page in ["home", "shop", "cart", "checkout"]:
    recent.append(page)
print(list(recent))  # ['shop', 'cart', 'checkout']
```

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

Updated: November 17, 2026

## In other subjects

- [Deque in Data Structures](https://www.ask-codey.com/glossary/deque-data-structures)
- [Deque in Java](https://www.ask-codey.com/glossary/deque-java)

Source: https://www.ask-codey.com/glossary/deque
