Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

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. 1

    Run the program: it prints Walks: 4 and ends with an error. Attach script.py with 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. 2

    Make the change the answer suggests, keep the list of walks as it is, and run the program. It prints Walks: 4 and Total: 36.

Back

1/7

  1. 1. The Whole Error
  2. 2. No Error, a Wrong Result
  3. 3. Quiz: Which Message Helps
  4. 4. The Fix Didn't Work
  5. 5. Quiz: Half a Fix
  6. 6. The Smallest Change
  7. 7. Summary
Next

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with: