5. Reading Between The Lines


#1

my code:

my_file = open("text.txt", "r")

print my_file.readline()
print my_file.readline()
print my_file.readline()

my_file.close()

the error I get:

Traceback (most recent call last):
File "python", line 1, in
IOError: [Errno 2] No such file or directory: 'text.txt'

I don't know what I did wrong, please can someone help me?


#2

Hello

In the text.txt window, go into that file, type something.
It is empty at the moment.
Go back to script.py and submit.

Hope that helps.


#3

it helped a lot and I found that if you remove the ! in the first line of text.txt, it also works. but thank you for help.


#4

That's good news.
Now you have two ways of solving the error you experienced.:grin:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.