Jan 26, 2026
# Chapter 11 — Iterators and Generators (Power Without Complexity)
This chapter is “show me the trick”.
## 11.1 Generator Function
```python
def countdown(n):
while n > 0:
yield n
n -= 1
for x in countdown(3):
print(x)
```
## 11.2 Why Generators Matter
- handle big data streams without storing everything in memory
- write clean pipelines
### Diagram: List vs Generator
```text
List: build all items -> store -> then loop
Generator: produce one -> use -> produce next -> use -> ...
```
---