Python File Input and Output - Error


#1

Hi,

I get the following error message, but actually my code seems to be fine:

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

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

print my_file.readline()

print my_file.readline()

print my_file.readline()

my_file.close()

It also says: "Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved."

I did that too, but the error still occurs.

Thanks a lot for your help.

Alex


#2

I've had this error before, the bottom part of this solution let it work for me