Text and collections
Choose and manipulate the built-in containers that organize text, sequences, records, and unique values.
Values, variables, and basic expressions from Getting Started.
Choose the right data structure for any task: strings for text, lists for ordered sequences, tuples for immutable data, dictionaries for key-value lookups, and sets for unique collections.
Read in order, or jump to what you need.
Every lesson builds on the one before it. Open any lesson to read the explanation, run the examples, and try the practice challenges.
- 02.01Strings and formatting4 min
Treat text as an immutable sequence and build clear messages from program values.
- 02.02String slicing and the text toolkit4 min
Use negative indices, stepped slices, escape sequences, and the string methods that everyday text work depends on.
- 02.03Lists and tuples4 min
Organize ordered values, change a working list, and unpack fixed groups of related data.
- 02.04Dictionaries and sets4 min
Use keys for meaningful lookup and sets for membership, uniqueness, and overlap.
- 02.05Mutability and copying4 min
Trace shared references, distinguish rebinding from mutation, and copy nested data intentionally.
Ready to move on?
Clean messy text strings, organize records into the appropriate collection, and demonstrate when a defensive copy protects the original from unintended mutation.
Open the module self-check