4/9 Did you create a variable called my_file?


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

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

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

What's wrong? :frowning:


I found this

    print("Attempting to open file")
    file  = open("some_txt_file.txt", "r")
    print("File Opened")
except IOError:
    print("Failed to load file!")
    file = open("some_txt_file.txt", "w+")
    print("File Created!")

then trying my code again. It's works :slight_smile:


The way I fixed mine was just to type something into "output.txt" and then flip back over to your python code and hit run.


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