01.03

Lists, dicts, sets, and tuples

skillmaxingPython with AILists, dicts, sets, and tuples
Visual lesson

Lists, dicts, sets, and tuples

Included with Pro · 4:45
Lessons · 989 words

Python ships four containers that between them hold most of the data a backend touches. A list is an ordered, growable sequence. A dict maps keys to values and remembers insertion order. A set holds unique items with fast membership tests. A tuple is a fixed sequence that cannot change. Everything else, from a JSON body to a database row to a model's tool call, arrives as some nesting of these four, so being fluent with them is most of being fluent in Python.

The choice between them comes down to four questions. Does order matter? Must items be unique? Will you look items up by a key? May the container change after it is built? A list of tickets in the order they arrived, a dict of tickets by id, a set of customer ids that have been notified, and a tuple for a database row are each the natural answer to a different combination.

Pro

Continue reading

Pro unlocks every video lesson, the full notes and runnable code across the Python with AI course, from the language itself to agents, MCP, Langfuse and deployment.

Unlock full access to
Python with AIAI researchComplete system design
30% off with LAUNCH30ends in 7h 40m
Buy now
View all plans ·Already Pro? Sign in
124 online