Reading Tracebacks & Common Errors
Lesson 1 of 5 · View course roadmap
Learn the idea
Errors are not failures — they're Python telling you exactly what went wrong. Read a traceback bottom-up: the last line names the error, the lines above show where.
The big five you'll meet constantly:
SyntaxError— Python can't even parse it (missing colon, unclosed quote)NameError— using a variable that doesn't exist (often a typo)TypeError— wrong type:"age: " + 25IndexError/KeyError— missing list position / dict keyValueError— right type, bad value:int("hello")
Pro habit: read the error name and message first, then the line number. 90% of bugs are solved by actually reading the message.
Where you'll use this
Reading tracebacks fast is the highest-leverage debugging skill — seniors resolve in seconds what juniors google for an hour, purely by reading the last line first and walking the stack.
Common mistakes
- Reading only 'something went wrong' and re-running unchanged code — the message literally names the problem and line.
- Fixing the traceback's top frame — the deepest frame (bottom) is where it actually raised; upper frames are just the call path.
- Shipping code with silent failure paths because an error 'went away' — understand why before moving on.
Pro tip
Paste the final line of any traceback into a search engine verbatim — TypeError: can only concatenate str (not "int") to str has been solved a million times. That's not cheating; it's the professional workflow.
Try it yourself
The lesson example is loaded and ready — press Run, then change something and run it again. Breaking it is part of learning. Want a clean slate? Tap “New blank”.
Output appears here…
Pass the challenge +25 XP
The starter code contains two bugs. Fix them so it prints Total: 30.
Total: 30
One NameError (typo), one TypeError (str + int). f-strings fix the second.
price = 10
quantity = 3
total = price * quantity
print(f"Total: {total}")
Run your code to check it…
Check your understanding
Your notes (saved on this device)
Tip: use ← and → to move between lessons, ⌘K to search everything.