practicepython.in
python exercises
171 exercises

Reading tracebacks

Every one of these starts with a real traceback, the only thing a crash leaves behind. The skill is reading it from the bottom, then asking where the bad value came from, because the line a traceback points at is where Python noticed, not always where the mistake is.

8 exercisesdifficulty 2–3~135 min in total
The stock count that tried to count the word quantitydebug reading a ValueError, the quoted value ~15 min The chart that crashes on the last daydebug reading an IndexError, the last iteration ~15 min The total that crashes on a price without a pound signdebug reading a traceback, a function that falls off the end ~15 min The podium that sorted into nothingdebug reading a NoneType error, methods that return None ~15 min The setting that is there and cannot be founddebug reading a KeyError, repr of a key ~15 min The digit sum that never reaches zerodebug reading a RecursionError, a base case that is never reached ~20 min The class list that will not sortdebug errors raised inside a built-in, None in data ~20 min The balance that exists and cannot be readdebug reading an UnboundLocalError, scope ~20 min