I am currently learning python and my instructor is telling me to open a text file using the open() meathod. I get the following error each time:
FileNotFoundError: [Errno 2] No such file or directory: 'movies.txt'
I have tried using online guides but all I could find was for .csv files, whereas I'm trying to open a text file. My complete code is as follows:
with open('movies.txt') as file_object:
contents = file_object.read()
print(contents.strip())
I've tried writing the file 'movies.txt' in VS code, and in my notepad, and then saving it to the same directory as the code but no use. I have also attempted to use a more exact file source, but still the same error. Sadly, google didn't have too much information for text files so I have to come here. Is there something I have to change in VS settings? I also tried my code in IDLE but not response either.
Thanks, Stan