I think there is a bug in "Reading Between the Lines". The text.txt file is not loading and run keep repeating "Reading Between the Lines". I have refreshed like 100 times but it happens every time
I get the same thing. I'm not sure how to get past it. I've tried both chrome and firefox. Refreshing didn't help nor did clearing my cache.
my_file = open("text.txt","r")
you are trying to open an existing file.....in read modus.....
If you use following code
you will see which files are available....
and will create the text.txt
import os print "==show us the existing files ==" files = [f for f in os.listdir('.') if os.path.isfile(f)] for f in files: print str(f) #my_file.close()
print "== if the file doesn't exist, create one ==" if os.path.exists('text.txt'): print "File exists" else: print "Creating the text.txt-file" my_file = open("text.txt", 'w') my_file.write("I'm the first line of the file!" +"\n") my_file.write("I'm the second line."+"\n") my_file.write("Third line here, boss."+"\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()
== discussions / opinions ==
@leonhard.wettengmx.n Thanks for the additional input.
The tutorial shows a text.txt tab with lines of text there, but for some reason it ends up not findable by the main script tab that runs the code:
with open('text.txt', 'r') as blah:
A workaround was to go into the text.txt tab and make a change.
I just added a fourth line to the text.txt file and then ran the code.
This seemed to get it to play nice, although my fourth line didn't actually print, it got me through the exercise.
Thanks for the heads-up! I simply went to the text.txt tab and added a few spaces after the third line, and managed to pass this question.
+1 It helped me as well
Hunveesy, thank you... didn't think of that, but it got me through the exercise +1
I was having the same problem. Not sure why they haven't fixed the bug. But use the link in this former post instead for that problem and it should work:
Thank you! you are the man!
Thanks a lot! You have gave me a big hand!