What is the problem with following code?


#1

txt.x is:
I'm the first line of the file!
I'm the second line.
Third line here, boss.

my code is:

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

I receive following error:
File "python", line 1, in
IOError: [Errno 2] No such file or directory: 'text.txt'
What is the problem?


#2

@simanii,
Please read
https://discuss.codecademy.com/t/my-program-cannot-find-the-text-txt-file/32576/2?u=leonhard.wettengmx.n
to get some more insight.....


#3

change content of the .txt file
u must keep 3 lines


#4

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