Bug in Reading Between the Lines


#1

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


#2

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.


#3

@hunveesy, @abhishekkumar1,

With
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()

Reference:
== discussions / opinions ==
http://stackoverflow.com/questions/11968976/list-files-in-only-the-current-directory
http://stackoverflow.com/questions/18533621/creating-a-new-text-file-with-python
http://stackoverflow.com/questions/5214578/python-print-string-to-text-file


#4

@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.


#5

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.


#6

+1 It helped me as well


#7

Hunveesy, thank you... didn't think of that, but it got me through the exercise +1


#8

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:


#9

Thank you! you are the man! :sunglasses:


#10

Thanks a lot! You have gave me a big hand!