Why does it say there is no such file?


#1

Question

Why does it say there is no such file?

Answer

Some users have had issues with the file they’re trying to open not existing, according to the terminal anyways. The solution seems to be making any slight change to the file, text.txt, and then going back to your Python file and running it again.
This is very unlikely to be the case, though. Be sure that you’ve properly opened the file by writing my_file = open("text.txt", "r").
Then you can print the result of my_file.readline() three times to see the three lines of the text file!


Learn Python - File Input / Output - Reading Between the Lines