Даже когда я успешно войду в систему, он все равно напечатает строку "пользователь неверен", как мне остановить это?
# Test Login userlist = {"user" : "password", "user2" : "password2"} login = input('do you have an account (Y/N)?') if (login == 'n'): New_User = input('create user: ') New_Pass = input('create password: ') userlist[New_User] = New_Pass loop = 'true' while (loop == 'true'): username = input("Please enter your username: ") for x in userlist: if (username == x): password = input("Please enter your password: ") if (password == userlist[x]): print ("Logged in successfully as " + username) loop = 'false' else: print ("Password incorrect!") else: print ("User incorrect")
Что я уже пробовал:
# Test Login userlist = {"user" : "password", "user2" : "password2"} login = input('do you have an account (Y/N)?') if (login == 'n'): New_User = input('create user: ') New_Pass = input('create password: ') userlist[New_User] = New_Pass loop = 'true' while (loop == 'true'): username = input("Please enter your username: ") for x in userlist: if (username == x): password = input("Please enter your password: ") if (password == userlist[x]): print ("Logged in successfully as " + username) loop = 'false' else: print ("Password incorrect!") else: print ("User incorrect")