Traceback (the majority of recent speak to last):File “python”, line 1, in IOError: No such file or directory: ‘text.txt’

Oops, try aacquire. Sorry, however I’m gonna need you to refresh the page! Don’t worry your code is conserved.

You are watching: Reading between the lines codecademy


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

I am obtaining the specific very same error (for two days now), while attempting to complete this leskid. My code is identical to yours.

redanaeem - I also had actually the same problem…

When I adjusted the code to list the records in the present directory:

import osprint os.listdir(".")The output was:

<"">So it appeared as if the required text.txt file didn’t exist.

So I wrote the code to create/compose the text.txt file so that it did exist:

my_file = open("text.txt", "w")my_file.write("I"m the first line of the file! ")my_file.write("I"m the second line. ")my_file.write("Third line right here, boss. ")my_file.close()Then when I checked the present magazine contents making use of the above code aget, i got:

<"message.txt", "">Now once I compose the code to settle the exercise, it functions OK.

stringer18 December 27, 2016, 11:27am #6

my_file = open(“message.txt”, “w”)my_file.write(“I’m the initially line of the file!” + ‘ ’ + “I’m the second line.” + ‘ ’ + “Third line right here, boss.”)my_file.close()

my_file = open(‘text.txt’, “r”)print my_file.readline()print my_file.readline()print my_file.readline()my_file.close()

First block is medicine, second - exercise.

See more: Illinois Pitbull Blue Nose Pitbull Puppies For Sale In Chicago

redanaeem December 26, 2016, 1:39am #7

this is also excellent bro

krishoza15sep December 27, 2016, 6:58am #8

include a brand-new line in the message.txt file that operated for me.

1 Like
ltox December 27, 2016, 1:48pm #9

Thanks for your solution
redanaeem, It functions perfectly


1 Like
vinceathor December 27, 2016, 8:46pm #10

I simply added " " approximately each of the lines and ended up getting it to job-related, probably that will help

1 Like
stetim94 closed December 27, 2016, 8:47pm #11
Home Categories FAQ/Guidelines Terms of Service Privacy Policy

Powered by Discourse, finest perceived through JavaScript enabled