Hello, the bellow code seems should have to work:

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

but instead it shows the error:

Oops, try again. Did you create a variable called my_file?


All You have to do is write on a few lines in the text file my_file and then your code will work and you will pass the SCT. :slight_smile:


Thanks, it worked! Probably, the instruction needs to be corrected..


We live, we learn. :smile:


there is no file as text.txt so make a new one like this:

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

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

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

Congratulations, you've finished this section! Next: The Devil's in the Details→

Well @aghabeg, this code worked! I think there is a glitch on your computer!?


WELL... its kinda wierd... i did it again and it gave me an error?
but it got it the first time... anyone knows why???


I think i got it... cuz the programme remembers what it has read before so such things will happen!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.