W WolfCode · CSC 141

Read the Traceback

读 traceback

≈ 15 min · python-debugging python-strings · Open in WolfCode

Parse a Python traceback as a string. Read it bottom-up: last line = error type, deepest frame = where the bug is.

Anatomy

Traceback (most recent call last):
  File "letter_grade.py", line 19, in <module>
    print(letter_grade(85))
  File "letter_grade.py", line 12, in letter_grade   ← deepest frame, usually the bug
    return grade
NameError: name 'grade' is not defined              ← error type + message

The two helpers

Python · runnable

The common runtime errors

ErrorMost likely cause
NameErrorTypo or used-before-defined
TypeErrorWrong type or arg count
IndexErrorIndex out of range
KeyErrorDict key not present
AttributeError ... NoneType ...Function returned None; you called .x on it
RecursionErrorForgot the base case
ZeroDivisionErrorDivided by 0