Lesson 1.2
Comprehensions and iteration
A comprehension is a filter and a transform in one line. Readable when the logic is small, unreadable the moment you nest three of them.
10mBeginner29,825 students

Sign in to watch this lesson
Browsing is free. Create an account to play videos and track your progress.
Overview
A comprehension is a filter and a transform in one line. Readable when the logic is small, unreadable the moment you nest three of them.
What this lesson covers
- Transform and filter a sequence in one expression
- Build dict and set comprehensions
- Know when a plain loop is clearer
This lesson sits in Python Foundations for Data, part of Python for Data Work. It assumes what came before it and leads directly into the next lesson in the module.
In this lesson you will:
- Transform and filter a sequence in one expression
- Build dict and set comprehensions
- Know when a plain loop is clearer