Answers for "Username and Password Login Function"

0

Username and Password Login Function

def login():
    attempt = 3
    username = input("Enter your username:n> ")
    while True:
     if username in userNamePassword:
        password = input("Enter your password:n> ")
        if userNamePassword[username] == password:
            print("Logged in")
            return True
        elif userNamePassword[username] != password:
            attempt -=1
            print("Sorry, the password is invalid. You have", attempt,"attempts remaining.")  
            login()
            if attempt == 0:
             print("Sorry, you have exhausted your password attempts. Please restart the process.")
             break
Posted by: Guest on January-07-2022

Code answers related to "Username and Password Login Function"

Python Answers by Framework

Browse Popular Code Answers by Language