Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
How do you retrieve the frame count from a dictionary named shot?
Show the answer
shot["frames"].
Turn a defined text format into typed fields
Parsing means finding structure inside text according to a stated format. This exercise uses exactly three simple pipe-delimited fields: name|frames|status. split("|") returns a list of strings in that order. List indices 0, 1 and 2 retrieve the fields.
The second field still contains text. int(parts[1]) converts it so arithmetic and comparisons use a number. A wrong separator can leave one field; indexing a missing second field raises IndexError. This worked example assumes the correct field count and valid numeric text. Day 14 teaches expected conversion failures; the review transfer adds explicit field validation.
Do not apply this simple split rule to quoted CSV with embedded delimiters. That format needs the CSV tools introduced later, not guesses about commas inside names.
# Parse the stated three-field training format.
line = "Tunnel|144|hold"
parts = line.split("|")
shot = {"name": parts[0], "frames": int(parts[1]),
"status": parts[2]}
# Use the converted number, not string concatenation.
print(shot["name"], "·", shot["frames"] + 1)The report is Tunnel · 145. If frames were stored as "144", adding the integer 1 would fail rather than perform this calculation.
Trace a split, fix a different delimiter, fill the scaffold, then return the three fields in a labelled dictionary. State the input preconditions before using a parser.
Predict, explain, then test
These three brief checks are self-reviewed, not a scored quiz. Explain your answer before opening the comparison. Coding checks test the stated data contract on unfamiliar inputs.
Predict a split
What list does "Canal|0|hold".split("|") return?
Compare your answer · self-reviewed
["Canal", "0", "hold"]. All three values are strings.
Explain a calculation
Why does parts[1] + "1" produce "01" instead of 1?
Compare your answer · self-reviewed
parts[1] is text, so + concatenates it. int(parts[1]) + 1 performs numeric addition.
Identify a precondition
What happens when a one-field line is split and the program reads parts[1]?
Compare your answer · self-reviewed
IndexError: there is no second field. Count fields before indexing when bad rows are possible; a later transfer task adds that policy.
Choose an exercise to load its prompt.
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.