teaching myself how to code and I need help
I'm trying to make sure the user inputs the right user name (credentials_U) and password (credentials_P)
DESIRED OUTPUT
- if they get both right it prints welcome
- if they only get the username right it prints wrong password
- if they get username wrong and or password wrong it prints incorrect and loops again.
CURRENT OUTPUT returns nothing
directory = {"ash":"123",}
def logon():
credentials_U = input("please input your username: ")
credentials_P = input("please input you password: ")
access = False
while access != True:
if credentials_U in directory:
if credentials_P in directory: #true and true
print ("welcome")
access = True
break
elif credentials_U in directory:
if credentials_P not in directory: #true and false
print ("incorrect password")
logon()
elif credentials_U not in directory:
if credentials_P in directory: #false and true
print ("incorrect")
logon()
elif credentials_U not in directory:
if credentials_P not in directory: #false and false
print ("incorrect")
logon()
else:
print("incorrect details")
logon()
Aucun commentaire:
Enregistrer un commentaire