Skip to main content

Lessons and exercises

The four built-in collections and the habit of choosing between them. Most of the awkwardness in beginner Python comes from solving a dictionary problem with parallel lists.

Lesson 3.3

Sets and Tuples

A set stores unique unordered items with fast membership testing. A tuple is an immutable sequence, which makes it hashable and usable as a dictionary key.

Lesson 3.4

Comprehensions and Iteration Patterns

A comprehension builds a collection from an iterable in one expression, and is clearer than an accumulating loop when the logic is simple.

Need help with this topic?

Work through questions with a tutor and get help with the steps you find difficult.

Get help with this topic