Reading


#1



https://www.codecademy.com/en/courses/python-intermediate-en-OGNHh/0/4?curriculum_id=4f89dab3d788890003000096#


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

Oops, try again. Did you create a variable called my_file?


this code passed then i went back and submitted again and now it won't work


my_file = open("output.txt", "r")
print my_file.read()
my_file.close()


#2

Hi @owen358,

That appears to be a bug in the exercise. The output.txt file disappeared for some reason.

Add this to the beginning of your code, so that it first creates the file if it does not yet exist, and then executes the code that you have already written ...

my_file = open("output.txt", "w+")
my_file.write("Norwegian Blue\n")
my_file.close()

#3

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