1

My Python file, which is just a very small file, will not read the contents of a .txt file in the same folder as the python file. The (very simple) code is below:

file = open("contents.txt", "r")

print(file.read())

file.close()

Even this will not work! The contents.txt file contains:

random data that the python file should read

Can anyone help?

P.S. No errors are produced, and the command prompt app just moves on.

1 Answers1

2

Never mind, it works. The file was located in a different folder, and once i brought it to the folder with the python file, it worked.