This exercise keeps telling me to refresh the page!


#1



Guys, I am stuck at exercise 5: Reading Between the Lines

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


There are no syntax or code mistakes. When I press on Save and Submit Code, it keeps on telling:

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

And in the console, it says:

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

This should actually give me the first three lines of text.txt in seperate lines.


I am sure there is no problem with my code:

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

Replace this line with your code.


#2

There are two(2) suggestions out of this.

One is to go over to text.txt and write, say "Success!"

Another is to go above your code and do:

with open("text.txt", "w") as textfile:
	textfile.write("Success!")

which opens text.txt and writes "Success!"

N:B - Ensure you're on the script.py tab before clicking on "save and submit"

I hope this helps!


#3

Thank you so so so so so so so so so so muuuuuuuccccchhhhhhh!!!!!!!!!!!!

You are great. The first one worked, I just went to text.txt and typed in success!

Thanks Thanks

:smile: :smile: :smile: :smile: :smile:


#4

You're welcome. And such feedback is heartwarming.

Have fun coding! :slight_smile:


#5

With pleasure :smile:


#6

I compleeeeeeeeeeeeeeeeeteeeeeeeeeedddddddddddd PPPYYYYTTTHHOOOONNNNNN!!!!!!!!!!!!!!!!!

YEEEEEAAAAAAAAAAAAAHHHHHHHHHHHHHH!!!!!!!!!!!!

So happy, so happy. @bayoishola20 Thanks for helping me.


#7

You're super welcome. :slight_smile:

You should get your hands "dirty" with more practice, and maybe, projects. :wink:


#8

You know, I can't afford codecademy's pro and do the final project. I like codecademy and love programming. I really need to get all those quizzes and stuff but I can't do anything about that so I will look forward to programming on my own. :slight_smile:


#9

Okay, that's fine.

You could try HackerRank for more practice.


#10

Thanks Thanks for the link. :smile:


#11

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