I have been trying to create a login system using a nested dictionary. The first dictionary contains the key as user_type and value as another dictionary of the key as user_name and value as a password. I wanted to check whether a username exists in a dictionary that is nested. I have been facing some errors.
Traceback (most recent call last):
File "main.py", line 130, in <module>
if uname in user.values().keys():
AttributeError: 'dict_values' object has no attribute 'keys'
My code is
user = {
"admin" : {"alex" : "1234", "phil" : "3453", "peter" : "23423", "lucas" : "12133"},
"student" : {"tanishk" : "23423", "sanskar" : "7445", "shashwat" : "5573", "ayush" : "96456"}
}
uname = input("Enter your username : ").lower()
if uname in user.values().keys():
print("Hello")