Text.txt does not exist Error


print my_file.readline()

What is wrong with this?
It says

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


yes, this exercise is indeed buggy, here is a good solution:

first write to the file, then read it.


I tried to refresh but it did not work. Glitch maybe????????????? I also did the second thing but that didn't work either.


Please make a new topic if you still struggle, since this topic is dedicated to helping microrunner75943


That worked. Thanks "stetim94"

Code I used:

f = open("text.txt", "w")
f.write("Hello World!" + "\n")
f.write("Hello World!!" + "\n")
f.write("Hello World!!!" + "\n")

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

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



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