5/9 Reading Between the Lines


#1

So I was writing the code and then suddenly the codecademy goes crazy.

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

this is the code i wrote and then codecademy told me "Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved"

I refreshed the webpage but no luck with that ither.
Plz help !!!


#2

It may be necessary to go back to the beginning and start over. Do all the lessons in order and in one sitting. Don't let your session be interrupted, else start over again.


#3

I got the same problem. I think the issue is we are trying to open a file in read only that does not exist and that's "text.txt". So I opened "text.txt" put data in it, then closed it. Then I did the exercise and it worked. Here is my code:

my_file = open("text.txt", "w")
my_list = [ i**2 for i in range(1,11)]
for item in my_list:
my_file.write(str(item) + "\n")
my_file.close()

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

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


#4

Not working (
But creating new "text.txt" and read it as described in lesson make this lesson complete )


#5

Hi, My problem is


How can I check it? Any idea?


#6

special thank's to extwhiz44584. I solved this task so


#7

I got the same problem, but i find way to solve it.I changed catalog to the text.txt which the site provided.And delete any letter of the file, then withdraw it.Now the file would be found.


#9

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