Traceback (most recent contact last):File “python”, line 1, in IOError: No such record or directory: ‘text.txt’

Oops, try again. Sorry, yet I’m gonna require you come refresh the page! Don’t issue your password is saved.

You are watching: Reading between the lines codecademy

```python

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


I am gaining the precise same error (for two days now), if attempting to complete this lesson. My password is similar to yours.


redanaeem - I additionally had the same problem…

When I changed the password to perform the records in the existing directory:

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

<"script.py">So it seemed as if the forced text.txt record didn’t exist.

So I composed the password to create/write the text.txt record so the it walk exist:

my_file = open("text.txt", "w")my_file.write("I"m the very first line of the file!\n")my_file.write("I"m the 2nd line.\n")my_file.write("Third line here, boss.\n")my_file.close()Then when I confirm the current brochure contents making use of the above code again, ns got:

<"text.txt", "script.py">Now once I create the password to deal with the exercise, it functions OK.


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

my_file = open(“text.txt”, “w”)my_file.write(“I’m the very first line that the file!” + ‘\n’ + “I’m the second line.” + ‘\n’ + “Third line 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, 2nd - exercise.

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


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

this is too great bro


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

add a brand-new line in the text.txt record that worked for me.


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

Thanks because that your equipment
redanaeem, It functions perfectly

*


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

I just included " " around each of the lines and also ended up acquiring it come work, probably that will help


1 prefer
stetim94 closed December 27, 2016, 8:47pm #11
home Categories FAQ/Guidelines state of service Privacy plan

Powered by Discourse, finest viewed through JavaScript enabled