Python, from your first line to your first library

CodeWithPurpose lessons that turn Python into a language you actually think in, not one you look up. Thirty-one chapters, no setup required.

Student learning Python

6. Data That Has Shape

7 chapters

Real data arrives nested, duplicated, and missing the key you asked for — the structures and habits that survive it.

DataInteractive

Sorting, Slicing, and the Methods That Return Nothing

Sorting a list of names is one function call, right up until the names have capital letters in them and the answer is quietly wrong. Sort the same list four ways, changing only the key, and watch the order rearrange itself under each rule.

11 min read

DataInteractive

A Row Is Just a Dictionary

A spreadsheet has rows and columns; Python has neither, and still holds the same data more honestly. Build a table out of nothing but a list and some dictionaries, then filter it down to three rows without ever writing a counter.

12 min read

DataInteractive

Structures Inside Structures

Every real API response is a dictionary holding lists holding more dictionaries, and the error for guessing wrong is four words long. Click down through a nested structure one level at a time and watch the access path build itself as you go.

12 min read

DataInteractive

Why Changing One Changed the Other

You copied the list, changed the copy, and the original changed with it. Point three different kinds of copy at the same nested list, mutate one item at the bottom, and see precisely which of them flinch.

11 min read

DataInteractive

The Errors Your Data Actually Throws

Three exceptions account for almost every crash involving real data, and each one names the exact thing that was not there. Ask a dictionary for a key it has never heard of, four different ways, and compare what each one hands back.

11 min read

DataInteractive

The Structures Python Ships But Never Advertises

Counting how often each word appears takes four lines and one conditional that everybody eventually gets wrong. Swap in the structure built for exactly that job and watch the same tally come out of a single line.

11 min read

DataInteractive

Picking One, and What It Costs

A list and a set both answer whether they contain something, and on ten thousand items one of them does ten thousand times more work to say so. Slide the collection size up and watch the number of checks each one performs pull apart.

12 min read

Open source

Your chapter goes here

Every chapter here was written by a student. Propose your own topic, or fix one that confused you. Drafts stay invisible until they are ready, so nothing you start can break the site.

Keep building your Python practice

These lessons are part of CodeWithPurpose's free learning library, built by students, for students, everywhere.