Reading Python Errors

Built-in AI tutor. It can see the code in the cell you are working on and the error you got. It points at the line and asks questions. It does not write the answer.

An error is Python telling you exactly where it stopped and why. The habit that makes errors fast to fix is the same every time: read the last line first. It names the kind of error and gives a message. The line number just above it says where in your code Python stopped. This page breaks code six ways on purpose. Run each cell, read the last line, then fix the cell and run it again.

The order to read a traceback in

1. The last line. The error type, like KeyError, and a message, like 'amount'. Most of the time this alone tells you the fix.
2. The line number above it. File "<exec>", line 3 means line 3 of your cell.
3. Everything above that. Where the call came from. Read it only when the first two do not settle it.
Two ways to work an error, both fine. Read it yourself first. Or click Ask about this error under the red box: the tutor gets the error line and can see your code, and it will point at the line rather than rewrite it for you.

The notebook

Run the cells top to bottom. Each one uses names from the cells above it, so skipping one gives a NameError further down. Edit any cell and run it again.

Check yourself

Two broken functions. Each stub runs into an error or a wrong answer as it stands. Fix it so the tests pass. Read the error before you change anything.