Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved


#1


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

Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved.


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

my_file.close()


5. Reading Between the lines
#2

I already did refreshed it , but still no luck


#3

In your text.txt file surround all your sentences inside the quotes like I did.

"I'm the first line of the file!"
"I'm the second line."
"Third line here, boss."

Then again you will get an error that my_file is not defined.
Then refresh the page and you'll go to go to next lesson.

update**
sometimes the above procedure may fail..
You can add one more sentence inside quotes (string) to text.txt file and hit submit
refresh and it will let you pass!
Do reply if it helps you or not! :slight_smile:


#4

Looks like this is the answer. I got an additional error that says that my_file was undefined but then clicking save/submit again without making any further changes worked like a charm. Thanks greentreemee


#5

Youre welcome! :slight_smile:


#6

Oh ok thanks :smiley: it worked


#7

Thanks, that worked! :smiley:


#8

Youre welcome and keep up the good work :thumbsup:


#9

This doesn't work for me. I keep getting the same error :disappointed:


#10

Have you tried to refresh the page?


#11

Yes, many, many times...


#12

What error you're getting ?
(Have you changed texts into strings?)


#13

Yes, I followed your suggestion but I keep getting:

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

And the message:

Oops, try again. Sorry, but I'm gonna need you to refresh the page! Don't worry your code is saved.


#14

click on submit multiple(1-2) times without refreshing the whole page..


#15

I'm getting the same error messages :disappointed:


#16

Okay there is a another method to pass it..thread is here..


#17

That worked, thanks! :grinning:


#18

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