File text.txt is not available


#1



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


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

I tried with "output.txt" which was created in the previous exercise, but that does not work either.


my_file = open('text.txt', 'r')
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()


#2

I think it's just Codecademy being buggy. Click on the text.txt tab above where you write your code and just type in a space or hit enter and then delete, then try again.


#3

I have tried that as well as reloading the page after clearing caches, etc. It just doesn't work.
Is there not someone from codecademy handling support when there are real errors?


#4

Ah, now I got it to work by just entering a space and deleting it again -- but in the "script.py" tab and not the "text.txt" tab.

Thanks for the suggestion.


#5

It worked..Thanks for the work around


#6

Thanks.
Space didn't work, but enter did. Weird stuff going on around here.


#7

I had to go to the text.txt and do the space then delete (anywhere in the file).


#8

Thanks, the hint to add and delete a character in text.txt worked for me, too!


#9

Solution

import os
print os.listdir(".")

testfile = open("text.txt", 'a')
my_file = open('text.txt',"r");

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

my_file.close()

#10

That worked. Thanks!


#11

Hi guys..
Why doesnt the [for] loop word for printing [readline()]s??


#12

*work.
I mean why cant we readline() using a for iteration loop?


#13

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