replit

Before you start this course, you must login to Replit

If you have forgotten your Replit account user name or password, ask your Coder Coach.

CoderSports

Read From A File

Need more help with file handling?

Predict and Run

What’s a Predict & Run task?

In these tasks you will be given one or more examples of code.

  • Look at each example , study it carefully.
  • Write a prediction of what it will do when it runs. Your prediction should be added to the code as comments.
  • Run the code, compare what happens to your prediction.
  • Add comments to note down and differences between your prediction and what actually happened.

Help! My code doesn’t work

Make sure that you check for the following things:

  • Include the file extension (.txt) in the file name
  • Use the exact same file variable with open and in the loop.
  • Use exactly the same case in the filename.
  • Indenting all the code that should be inside loops.
  • Close the file once task is completed.

Hints