This python code right here should open a text file in the same directory where I put my ex15.py and read it but there seems to be a problem it always says there's a problem in line 5 and it can't the text file in the same folder:
C:\Users\GAMING>py C:\MyCodes\PythonCodes\ex15.py ex15_sample.txt
Traceback (most recent call last):
File "C:\MyCodes\PythonCodes\ex15.py", line 5, in <module>
txt = open(filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ex15_sample.txt'
Code:
from sys import argv
(script, filename) = argv
txt = open(filename)
print(f"Here's your file {filename}:")
print(txt.read())
print("Type the filename again:")
file_again = input("> ")
txt_again = open(file_again)
print(txt_again.read())