Py

Comprehensions & Iteration

Module 9 of 14, Intermediate
⚡

Comprehensions & Iteration

Build collections in one line with comprehensions, loop smarter with enumerate and zip, sort with keys, and stream values with generators.

0 of 5 lessons complete

5 lessons, 49 min

Start module

Lessons

1

List comprehensions

Transform and filter a list in a single readable line.

10 min
2

Dict and set comprehensions

Build dictionaries and sets with the same one-line syntax.

9 min
3

enumerate() and zip()

Loop with an index, or walk through several lists side by side.

9 min
4

Sorting with key functions

Sort, rank and pick winners by any rule you like.

10 min
5

Generators and lazy iteration

Produce values on demand with generator expressions and yield.

11 min
🛟
Next module

Errors & Exceptions