import ast
Account = {
"username": "",
"password": ""
}
firstQ = input("1:reg, 2:login, 3:quit")
def reg():
Account["username"] = input("username: ")
Account["password"] = input("password: ")
AccountList = open("/Users/user/Desktop/acList.txt", "a")
n = AccountList.write(str(Account) + "\n")
AccountList.close()
def login():
with open("/Users/user/Desktop/acList.txt", "r") as f:
readAcc = f.read()
realAcc = ast.literal_eval(readAcc)
loginUsername = input("login with user: ")
loginPassword = input("login with pass: ")
if loginUsername in readAcc and readAcc[realAcc] == loginPassword:
print("you are logged in as:" + realAcc["username"])
if firstQ == "1":
reg()
elif firstQ == "2":
login()
else:
quit()
when trying to register multiple "account" I get a syntex error: invalid syntax. And when trying to log in to an account when you just have one account registered, I get a type error: string indices must be integers. Feel free to copy my code into your own editor as I may not have explained the error messages that well