Programming foundations

Stage 1 · Lesson 5 of 9

Reading tracebacks and debugging

Your first language

Errors are information, not failure. When Python crashes it prints a , a report of what went wrong and where. Read it from the bottom up.

The last line names the (the kind of error), such as TypeError or KeyError, with a message. The lines above show the file and line where it happened, and the chain of calls that led there. Most beginner bugs are fixed by reading that last line slowly.

Sometimes there is no error but the output is wrong. Then check your assumptions: print the values just before the suspicious line. Better still, set a breakpoint in your editor, a marker where the program pauses, and step through line by line while watching the variables.

Learn this now, because from here on you will spend more time reading errors than writing new code.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Small exercises in your language track, with free feedback from a human mentor

Keep handy

  • The official tour: read the matching chapter after the course covers a topic

  • Quick syntax lookups and an online compiler for testing a snippet on a shared computer

Mark this stage as not done?