I am working on a project for my class and I am stuck on this extra credit part. I am building a password and username checker to check against a list of dictionaries that have the username and password.
I have tried many methods but cannot seem to get the result i need. The problem with the code I have is that it does not compare the password with the associated username. It results in TRUE if the password is in any dictionary. Any help would be appreciated as I will keep plugging along myself
This is what I have:
adminList = [
{
"username": "DaBigBoss",
"password": "DaBest"
},
{
"username": "root",
"password": "toor"
}
]
#Import Required Tools
import getpass
####################################
### Define ALL FUNCTIONS ###
####################################
#Define function to confirm login credntials of the user
def getCreds():
user_name = input("Please input your user name: ")
while not any(d["username"] == user_name for d in adminList):
print("User name not recognized, please try again.")
getCreds()
pass_word = getpass.getpass("Please enter your password: ")
print("Checking Credentials")
while not any(d["password"] == pass_word for d in adminList):
print("The password in not correct")
pass_word = getpass.getpass("Please enter your password again: ")
else:
print ("Hello and welcome to the Matrix.")
#Call the getCreds function
getCreds()