Errors in Python Unit 12: Lesson 5


#1

I think there are a few small errors on the Python Skills course. The biggest one is
in Python's Unit 12: Lesson 5. The editor doesn't recognize the "text.txt" file.


#2

Can you please explain in detail the error on lesson 5? Like the code you tried, the error generated and exercise link with screenshot. Thanks a lot! :smiley:

Note that the editor might not recognize the text.txt file on the first try. That's a technical glitch. But it will pass on re-submission of the correct code.


#3

my_file = open("text.txt", "r")

print my_file.readline()
print my_file.readline()
print my_file.readline()

my_file.close()

Traceback (most recent call last):
File "python", line 1, in
IOError: [Errno 2] No such file or directory: 'text.txt'

Python Unit 12: Lesson 5


#4

Definitely. That's a bug due to problematic file environment. I will add this to reported bugs list.


#5

for getting around it


#6

I just copypasted some code from a later lesson to make the file

with open("text.txt", "w") as textfile:
textfile.write("I'm the first line of the file!" "\n")
with open("text.txt", "a") as textfile:
textfile.write("I'm the second line." "\n")
with open("text.txt", "a") as textfile:
textfile.write("Third line here, boss.")

my_file = open("text.txt", "r")

print my_file.readline(),
print my_file.readline(),
print my_file.readline()

my_file.close()


#7

It works, man! Thanks.


#8

I still have this problem on Lessons 5 and 8


#9

Yes, there is some kind of bug in this lesson. Very frustrating. But your solution worked. Thanks.