Reading files with Python

Hi everyone. I’m fairly new to Python and I’m following this course my workplace provides. It shows the following code to read a file:

a = open(“demo.txt”, “r”)
print(a.read())

Now, I’ve created a demo.txt doc in the same location as the py file but still comes back with the following:

image

Can anyone help? I am literally following this step by step and still no cigar :confused:

Thanks!

Hi @jubedmiah:

Please make sure you place to file to be read and the python file in the same base directory. for example:

c:\Users\test\Desktop\pythonexercises
|
|------ Reading_files.py
|
|------ demo.txt