Hello,
I have made myself a little log in code but i have an issue,
When the account exists i get the error that the username or password is incorrect, i have looked through my code and just can not understand what i have done.
Here is the code:
There is no actual error, its more of a bug that im unable to rid of, meaning that i cannot actually give you the error a part from the fact that it tells me that the account doesn't exist when attempting to log in even though it does exist.
I have made myself a little log in code but i have an issue,
When the account exists i get the error that the username or password is incorrect, i have looked through my code and just can not understand what i have done.
Here is the code:
def loginReg(): welcome = input("Do you have an acount? y/n:\n>> ") if welcome == "n": while True: username = input("Enter a username:\n>> ") password = input("Enter a password:\n>> ") password1 = input("Confirm password:\n>> ") try: if username in open(username+".txt").read(): print ("Error: Username already exists") loginReg() except OSError as e: if password == password1: file = open(username+".txt", "w") file.write(username+":"+password) file.close() welcome = "y" break print("Passwords do NOT match!") loginReg() if welcome == "y": while True: login1 = input("Username:\n>> ") login2 = input("Password:\n>> ") try: data = open(login1+".txt", "r") except IOError: print('Error: File does not exist [001]') loginReg() file = open(login1+".txt", "r") file.close() if data == login1+":"+login2: print("Logged In") main() print("Incorrect username or password.") loginReg() else: print("Error: Invalid input") loginReg()I get line 36 if im trying to log in with an account that exists
There is no actual error, its more of a bug that im unable to rid of, meaning that i cannot actually give you the error a part from the fact that it tells me that the account doesn't exist when attempting to log in even though it does exist.