I keep on getting the error message:
SyntaxError: invalid syntax
>>> & C:/Users/natsu/AppData/Local/Programs/Python/Python313/python.exe "d:/aaPytho\n Files/passwordManager.py"
File "<python-input-5>", line 1
& C:/Users/natsu/AppData/Local/Programs/Python/Python313/python.exe "d:/aaPython Files/passwordManager.py"
And my code looks like:
from cryptography.fernet import Fernet
'''
def write_key():
key = Fernet.generate_key()
with open("key.key", "wb") as key_file:
key_file.write(key)'''
def load_key():
file = open("key.key", "rb")
key = file.read()
file.close()
return key
master_pwd = input("What is the master password? >> ")
key = load_key() + master_pwd.encode()
fer = Fernet(key)
def view():
with open('passwords.txt', 'r') as f:
for line in f.readlines():
data = line.rstrip()
user, passw = data.split(" ")
print("User:", user, "| Password:", str(fer.decrypt(passw.encode())))
def add():
name = input('Account Name: ')
pwd = input('Password: ')
with open('passwords.txt', 'a') as f:
f.write(name + "|" + str(fer.encrypt(pwd.encode())) + "\n")
while True:
mode = input("Would like to add a new password or view existing ones (view, add)? ").lower()
if mode == "q":
break
elif mode == "view":
view()
elif mode == "add":
add()
else:
print("Invalid mode.")
continue
Does anybody know what this means? My code seems fine since I’m following a tutorial.
I’m running Python version 3.14.0 on VS code.
UPDATE: The same problem happens for all other files that I try to run on VS code.