Lists, Tuples, Dictionaries and Sets
Lists, tuples, dictionaries and sets: how each works inside, how to copy them safely, the collections toolbox, and how to choose the right one.
So far each variable has held one value. Real programs hold many: the items in a cart, the scores of a class, the settings of an app, the messages of a chat. This phase teaches the four built-in containers that Python gives you for that: the list, the tuple, the dictionary and the set.
You will learn how to use each one, and also how each one works inside: why a dictionary finds a key almost instantly, why a list cannot be a dictionary key, why copying a list does not always copy what is in it. These ideas explain most of the surprising bugs beginners meet, and they are the same ideas interviewers ask about.
The phase ends with comprehensions (a short way to build containers), nested data (the JSON-shaped data that every web API and AI model API returns), the collections toolbox, and a plain-words guide to what each operation costs, so you can choose the right container on purpose.
Practise this phase
Hands-on exercises: write the code, run it, and press Check to have it tested automatically.