MODULE 02 · BEGINNER

Text and collectionsPython · Module 2

Choose and manipulate the built-in containers that organize text, sequences, records, and unique values.

5 lessons20 min readingWrite clear Python
Free, self-paced, and open to everyone. No account needed.
WHAT THIS MODULE COVERS

Text and collections

Choose and manipulate the built-in containers that organize text, sequences, records, and unique values.

BEFORE YOU START

Values, variables, and basic expressions from Getting Started.

WHAT YOU’LL BE ABLE TO DO

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.

THE LESSON SEQUENCE

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.

  1. 02.01
    Strings and formatting

    Treat text as an immutable sequence and build clear messages from program values.

    4 min
  2. 02.02
    String slicing and the text toolkit

    Use negative indices, stepped slices, escape sequences, and the string methods that everyday text work depends on.

    4 min
  3. 02.03
    Lists and tuples

    Organize ordered values, change a working list, and unpack fixed groups of related data.

    4 min
  4. 02.04
    Dictionaries and sets

    Use keys for meaningful lookup and sets for membership, uniqueness, and overlap.

    4 min
  5. 02.05
    Mutability and copying

    Trace shared references, distinguish rebinding from mutation, and copy nested data intentionally.

    4 min
MODULE SELF-CHECK

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