I'm making a simple login system in Python where you have to fill in an email adress and password. When the email and password you just filled in are true, it should only display that and not that the other possible emails and passwords are wrong, as listened below:
loginInformation = {
1: {"firstName": "Bert", "lastName": "de Vries", "emailAdress": "bert@gmail.com", "password": "volkswagen"},
2: {"firstName": "Kristina", "lastName": "van Goor", "emailAdress": "kris94@hotmail.com", "password": "feyenoord"},
3: {"firstName": "John", "lastName": "Doe", "emailAdress": "johndoe@gmail.com", "password": "paashaas"},
4: {"firstName": "Sophia", "lastName": "Smith", "emailAdress": "soso@outlook.com", "password": "kerstman"}
}
givenEmailAdress = input("Please enter your email adress: ")
givenPassword = input("Thank you! Please enter now your password: ")
for key, info in loginInformation.items():
firstName = info["firstName"]
lastName = info["lastName"]
emailAdress = info["emailAdress"]
password = info["password"]
if(givenEmailAdress == emailAdress and givenPassword == password):
print("Hello",firstName,lastName,", you have successfully logged in.")
else:
print("Your password and email adress are wrong.")
Example: When you fill in key 3, it should show:
Hello John Doe , you have successfully logged in.
But it is unfortunately showing:
Your password and email adress are wrong.
Your password and email adress are wrong.
Hello John Doe , you have successfully logged in.
What am I doing wrong? I assume it should be a quick fix. Thanks in advance!