Interpreter returns unrecognized file exception


#1

The code bellow is what the lessons requires but the interpreter keeps returning an error apparently the text file which is right next to the python file doesn't exist. I also keeps telling me to refresh the page but wont't fix anything iv'e been trying for a few hours.

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

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

my_file.close()


#2

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

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

my_file.close()

they ask for print out


#3

I am having the same issue as mentioned and my program is the same.


#4

I found a work around

with open("text.txt","r") as my_file:

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

my_file.close()