Quiz

Name the Culprit

The error type on the last line of a traceback is your best clue. Each type points to a few usual suspects:

Error Usual suspect
NameError a typo, or a name used before it was made
TypeError the wrong type, like "5" + 3, or calling None
AttributeError the object isn't what you think (often None)
KeyError a dict key that isn't there (check spelling and case)
IndexError a list position past the end (often off by one)
ValueError the right type with a bad value, like int("ten")
ZeroDivisionError dividing by zero, often by len([])

None is a famous suspect. A function with no return gives back None. So do list methods that change the list in place, like .sort() and .append().

A traceback ends with `AttributeError: 'NoneType' object has no attribute 'append'`. What is the most likely cause?