All learning paths Learn See Try Make Read an error message properly What this lesson is about Find the line, the cause and the fix inside a wall of red text, from the bottom upwards.
Your program stops and fifteen red lines fill the screen. You have ten minutes. Where do you look?
A Paste the whole red block to an assistant and use whatever it changes. B Open the line number the message points at and fix whatever sits on that line. C Read an error from the bottom up: the last line says what went wrong.
Check my recall Why this matters The Python tutorial says the last line of the error tells you what happened. The lines above it show where. Reading upward from there beats reading the whole wall.
You can find the line, the cause and the likely fix inside a wall of red text.
The Python tutorial says the last line of the error tells you what happened. The lines above it show where. Reading upward from there beats reading the whole wall.
Read an error from the bottom up: the last line says what went wrong. The four you meet most: a missing name, a wrong type, a bad value, a divide by zero. The line it names is where it broke, not always where the mistake is. Task A program stops with fifteen red lines ending in a wrong type message.
Weak approach Pasting the whole red wall to an assistant, taking back a changed line, and running it again. It works, and nobody can say which value was wrong or where it entered.
Stronger approach Reading the last line first: a number was joined to a piece of text. Then finding the earlier line where the text came in.
Why the stronger approach works The error named line twelve, but the wrong value entered at line four. Saying which is which is the job.
Try a changed situation A government portal refuses your form and shows one line at the bottom about a missing document. What do you check?
Make something yourself Break one working program three different ways on purpose. For each break, paste the error, name the line it points at, and write the fix you made.
Lesson 3 of 10 on Coding for evaluation work next Run a test and read the result Part 1 ends in a work sample you can send The rules this work sample is read against
Read the primary or official source: Python documentation · errors and exceptions