Guided Notes

Error Handling

Reading tracebacks, common exceptions, try/except/else/finally, and raise.

Reading a traceback

Slide 1 / 5

When something goes wrong, Python stops and raises an exception, printing a traceback.

Read it from the bottom up. The last line names the exception type and message:

ZeroDivisionError: division by zero

The lines above show the chain of calls that led there, ending with the exact file and line number where it happened. Start at that line — the real mistake is usually there or just before it.

← Strings