Apr-02-2021, 04:58 AM
You should not test for Adrian or mad or any other user name. You should take the name and then check if the name is valid. In this example I have a dictionary mapping user names to passwords.
users = {"Adrian":"Rocky", "mad":"world"} def login(): name = input("Username: ") password = input("Password: ") if users.get(name, None) == password: return name return None if name := login(): print(f"Welcome {name}") else: print("Invalid username and/or password")The idea is to avoid writing code for a particular case and instead write code that is generic. This code doesn't care who the users are or what the passwords are. All it cares about is that someone entered a username/password pair that matched an entry in the user database.