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

Things That Aren't Here

An answer can be right about Python and still not work where your program runs. The assistant can't see where that is, so unless you say it, it writes for an ordinary computer, with your files on it and any library it needs installed. A library is code that other people wrote, which a program takes in with import; on a computer of your own, you install the ones you need.

Your programs here run in your browser, on this page. There are no files of yours for them to open, and the libraries you'd install on your own computer aren't installed here. An answer that saves Mia's walks to a spreadsheet with the library openpyxl, for example, stops at its first line:

Traceback (most recent call last):
  File "<exec>", line 1, in <module>
ModuleNotFoundError: No module named 'openpyxl'

Such an error doesn't mean that the answer made something up: openpyxl exists, and a file the program opens may well exist on someone's computer. It means that it isn't here, and only you know that. Ask without saying it, and you get help for another computer: sent the program in the editor and its error with just How do I fix this?, one answer suggested creating the file, checking which folder Python runs in, and writing out the file's whole path.

In Say What the Code Should Do, you told the assistant where a program runs. Whoever got this one didn't: it reads Mia's walks from a file, walks.txt, with a number of minutes on each line. Her walks this week were 30, 45, 20, 60 and 25 minutes.

Instructions

  1. 1

    Run the program: it ends with a FileNotFoundError. Attach script.py and, with the console's button, what it printed. Say where the program runs: in a browser, on a learning site, where it can't open files or install libraries. Give Mia's walks, and ask for a version that works there. Then send it.

  2. 2

    Copy the program from the answer, paste it into the editor in place of yours, and run it. It prints Walks: 5 and Total: 180.

Back

2/6

  1. 1. A Method That Doesn't Exist
  2. 2. Things That Aren't Here
  3. 3. Quiz: An Older Version
  4. 4. Try It in Three Lines
  5. 5. Quiz: Check the Claim
  6. 6. Summary
Next

Start programming for free

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

Or sign up with: