Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
Without scrolling back — what does the = sign actually do in frame_count = 240?
Show the answer
Answer. It puts 240 into the box labelled frame_count — right side into left side, never the other way.
Keep an ordered collection
Your outcome: Create a list and retrieve its first, middle and last elements by index.
Square brackets create a list. Commas separate its elements; each filename or label is a quoted string. Order matters: a shot list is not a set.
An index is a zero-based position. In three items, 0 selects the first, 1 the middle and 2 the last. shots[3] asks beyond that list and raises IndexError; it does not create a fourth shot.
Keep the requested collection name and input items. Retrieve the output from the list with indexing instead of printing a copied label. A negative index such as -1 also selects the last item, but the nonnegative positions are enough for this lesson.
# Keep an ordered collection
shots = ["wide", "medium", "close-up"]
print(shots[0])
print(shots[2])
Trace: shots holds three strings in order. The first lookup returns wide; the second returns close-up. Two print calls produce two lines.
A list holds multiple values in order. Test yourself with a four-item list and explain the first and last positions before running.
Predict, explain, then test
Answer before opening the comparison. These brief answers are self-reviewed, not quiz scores. Task labels describe the brief, not proof that you worked without assistance. Record any examples, hints or tutor help in your own Notes.
Predict
For takes = ["A", "B", "C", "D"], what is takes[3]?
Compare your answer · self-reviewed
D. Four elements have positions 0 through 3.
Explain
Why is printing "close-up" not the same practice as printing shots[2]?
Compare your answer · self-reviewed
The literal does not read the collection. Indexing would retrieve a different value if the list changed.
Repair
A three-item list raises IndexError at index 3. What should you inspect?
Compare your answer · self-reviewed
Count the actual items and the requested position. The last nonnegative index is 2; do not suppress the error or invent a missing item.
Choose an exercise to load its prompt.
Today's idea in two other voices, if you want one. Not required — the exercises above are the actual lesson.
- Lists vs Tuples in Python — article, Real Python
- Python Tutorial for Beginners 4: Lists, Tuples, and Sets — video, Corey Schafer
Loading exercises…
Noted on your route map, with the step you were on. Nothing is lost by parking it — the next review day will bring this idea back, and the flag tells the course where to slow down.
The tutor mounts here when JavaScript is available. The lesson above stays readable without it.