The Whole Error
An assistant can't run your program. Asked only why it doesn't work, it reads the code and works out what might go wrong. In a program of a few lines, it often gets there; in a long one, a mistake has many places to hide. The error message doesn't have to work anything out: Python wrote it when your program stopped, and it says what went wrong and where.
So when a program ends with an error, send the AI the program and the whole error. The console has a button for the second, Attach to message: it sends what the program printed as output.txt, every line it printed before it stopped and then the whole error. Send all of it, not only the last line, and don't retell it: “I get some error about a variable” leaves out exactly what the AI needs.
Mia has added a function, week_total(), that adds up what the week's walks cost, and her program now ends with an error you haven't met. It has two lines that start with File: the program called week_total() on line 16, and inside it, line 10 is where it stopped. The mistake is often on the line where a program stops, but it can also be on a line that ran before it, which is one more reason to send the program with the error. The last line says what went wrong, in words that are hard to follow. That's a question for the AI.
Instructions
- 1
Run the program: it prints
Walks: 4and ends with an error. Attachscript.pywith Attach to message over the program, and what it printed with the same button on the console. Ask what the error means and what's wrong. Then send it. - 2
Make the change the answer suggests, keep the list of walks as it is, and run the program. It prints
Walks: 4andTotal: 36.