Hello,
I'm trying to make a simple login page through the terminal and I decided to use a dictionary to store the user's name and password.
As show in my code here (Ya I realize now, I probably don't need the whole function housing the dict):
And I have an input statement that takes in the user's name and password as shown here:
My question is: how do I validate the user's name and password in an if statement so they can get to the menu? (How do I check to make sure the key, value pairs in the dict match, and apply them to my validate function)
Thanks in advance.
I'm trying to make a simple login page through the terminal and I decided to use a dictionary to store the user's name and password.
As show in my code here (Ya I realize now, I probably don't need the whole function housing the dict):
def StandardUsers(): users = { "Bob" : 1234, "Jim" : 5678, "Roger" : 9101, "Frank" : 8877 } return users def SuperUsers(): admins = { "Joe" : 0000, "Randall" : 1111 } return admins(Ex: "Bob":1234 Where "Bob" is the user's name and 1234 is the password)
And I have an input statement that takes in the user's name and password as shown here:
def login(): print('=============================') print('= Login =') print('=============================') user = input("Enter your name: ") password = input("Enter your password: ") validate() #Go to validate functionAnd this is my validate function that I have right now:
def validate(user): #if StandardUsers enters in correct name and password: MainMenu() #if SuperUsers enters in the correct name and password: AdminMenu() else: print('You are not registered to use this program') login()
My question is: how do I validate the user's name and password in an if statement so they can get to the menu? (How do I check to make sure the key, value pairs in the dict match, and apply them to my validate function)
Thanks in advance.