Python ships a small set of built-in functions designed for working with collections: map, filter, zip, enumerate, sorted, any, and all. They turn loops that span ten lines into one-liners.

You’ll see these everywhere in data and ML code, so the goal of this section is to make them feel as natural as if and for.

What’s in this section

  1. map and filter — transform and select items
  2. zip and enumerate — combine and number sequences
  3. sorted — sort by anything with a key function
  4. any and all — ask “any of these true?” or “all of these true?”

By the end, the difference between a beginner and an intermediate Python developer is mostly comfort with these.

Toggle theme (T)