Thirty test scores could mean thirty variables — or one list. Lists are how programs hold a whole collection under a single name, and they come with the second big flip of the unit.
Focus on creating a list and pulling a value out by index. Enrolled in our Runestone course? Open it from there so your progress counts.
Still in Programs, opening Week 2. Loops let you repeat an action; lists give you a collection to repeat it over. Together they’re the engine of almost every real program — and of the accumulator you just learned.
A list fixes it: one name,
scores, holding all the values in order. You reach any one by its position
— its index — and you can loop over the whole thing at once. This is
the tool that makes loops worth having.
A list holds values in order. Each value is an element, and each
element has an index — its position. You read an element with square brackets:
scores[0].
scores[0]. AP Pseudocode counts starting at
1: the first element is scores[1]. Same list, different position
numbers. This appears in warm-ups every week from now on, because it is one of the two
most-missed mechanical ideas on the exam.
Here is one list, labeled both ways at once — the picture to keep in your head:
| value | 85 | 90 | 78 | 92 |
|---|---|---|---|---|
| Python index | 0 | 1 | 2 | 3 |
| AP index | 1 | 2 | 3 | 4 |
scores = [85, 90, 78, 92] print(scores[0]) # 85 (first) print(scores[2]) # 78 scores[1] = 100 # update
scores ← [85, 90, 78, 92] DISPLAY(scores[1]) /* 85 (first) */ DISPLAY(scores[3]) /* 78 */ scores[2] ← 100 /* update */
Hover or tap a line to light its twin. Both grab the same elements — the first (85) and the third (78) — but the position numbers differ by one. Read the notation, then count from its starting point.
scores is a single name
standing in for a whole collection, and you can pass it around, loop over it, or grow it without
caring how it’s stored. Third rung of the same ladder.
Click an element to see its Python index and its AP index side by side. Same box, two position numbers — burn the picture in.
Five questions. For each, write the list out and count from the right starting point (0 for Python, 1 for AP). Then pick your answer.
Your playlist, your contacts, a feed of posts, search results, the high-score table, the frames of a video — all lists. The moment an app shows you “a bunch of things in order,” there’s a list behind it, and a loop walking through it. Lists are how software handles many instead of one.
The 0-vs-1 flip isn’t just an exam quirk, either. Real bugs come from “the first item” meaning index 0 to one programmer and index 1 to another. Whole categories of software errors are off-by-one mistakes at the edge of a list. Knowing exactly where counting starts is a professional habit.
append, remove,
and building a list from user input inside a loop.