I'm very new to programming, and to vscode.
I'm learning Python and currently I am learning about working with files.
The path looks like this: /home/anewuser/learning/chapter10.
The problem: completely basic "read file in python" lesson does not work in vscode because no such file or directory error raises when running my .py file, located in ~/learning/chapter10. But vscode wants that my .txt file I am supposed to open in python, to be in ~/learning directory, then it works. I don't like this behaviour.
All I want is to be able to read file placed in the directory where the .py file is. How to do this?
openfunction?with open('pi_digits.txt') as file_object: contents = file_object.read() print(contents)Error:Traceback (most recent call last): File "/home/anewuser/learning/chapter10/file_reader.py", line 1, in <module> with open('pi_digits.txt') as file_object: FileNotFoundError: [Errno 2] No such file or directory: 'pi_digits.txt'When i put both .py and pi_digits.txt in~/learning/chapter10, this error happens. When I put 'pi_digits.txt' in~/learningdirectory, it works. What to do make it work in the same directory? Thanks!