4/9 Did you create a variable called my_file?


#1


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()
my_file.close()

What's wrong? :frowning:


#2

I found this

try:
    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:


#3

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.


#4

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