Work Around for "Reading between the Lines"; text.txt does not exist error


#1
From an old post: Bug? 5/9 (Reading Between the Lines) 'text.txt' file not found

Bug? On File Input/Output part 5/9 (Reading Between the Lines) I get an error like 'text.txt' file not found. The code is my_file = open("text.txt", "r") print my_file.readline() print my_file.readline() print my_file.readline() my_file.close() I don't think there is anything wrong with the code because if I skipped this part and do the 6/9 (PSA: Buffering Data) first the text.txt file will be created and the 5/9 will run just fine.

My Question: Wait, what? "Typing any character or a space on the .txt " Not sure I understand what this means. Are you editing the text.txt file some how? or putting a space in the code? I'm getting the same error and the "helpers" are telling me it is a connectivity issue. Looks like not so much.


#2

I just made the file, it passed me on to the next excercise

fixit = open("text.txt", "w")
fixit.write("I'm the first line of the file!" + "\n")
fixit.write("I'm the second line." + "\n")
fixit.write("Third line here, boss." + "\n")
fixit.close()

5. Reading Between the lines
#3

Ay that was the rub. All fixed. Thanks for the advice!@!


#4

Thanks for sharing. Nice help!!!!


#5

If you alter the text.txt file (go to the tab on the top) in any way your answer will be accepted.

Delete a character, or better yet, just add a space in the end of a line and then you can submit your code.


#6

Thanks for the solution, it works great.


#7

thnku this helps alot


#8