I was curious what would happen if i ran my code without the .close() file since codecademy kept telling me it's a bad idea, which I ran it without the .close() command. After that I kept getting these two errors.
the errors i'm getting from the compiler is,
Traceback (most recent call last):
File "python", line 1, in
IOError: [Errno 2] No such file or directory: 'text.txt'
from codecademy i'm getting,
Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved.
I expect this to print out the three lines in the text.txt file. I've refreshed my browser and even deleted my cookies/browsing history to try to make the errors go away. Any suggestions would be nice
my_file = open("text.txt", "r") print my_file.readline() print my_file.readline() print my_file.readline() my_file.close()