Summary
In this lesson, you learned that:
- The AI can't run your program. When it ends with an error, send the program and the whole error, with the button on the console. The error says what went wrong and where the program stopped; the mistake is often on that line, but it can be on one that ran before it.
- When the program runs and its result is wrong, nothing tells the AI so. Say what the program prints and what you expected instead, with the numbers, and why, when it depends on a rule the AI can't know.
- When a fix doesn't work, go on in the same chat: attach the program again, and say what you changed and what it does now. Python stops at the first error, so one mistake can hide another, and an error can go away while the result stays wrong. Check the result again.
- Ask for the smallest change: which line, how and why. A whole new program hides what was wrong, and it can change lines that were fine.
Practice it all at once. Mia's program prints one number and then ends with an error about NoneType, on a line that looks right.
Next comes a small project, Checkpoint: The Price List, where you build Mia's price list with the AI, one function at a time.
Instructions
- 1
Run the program. Attach
script.pyand what it printed, and ask which line to change and why. Ask for only that line, not the whole program again. Then send it. - 2
Change that line, keep the list of walks as it is, and run the program. It prints
Walks: 4andTotal: 36.