I'm creating code that creates new user identifications for users, and then adds all their account details to a dictionary and then adds this dictionary to another dictionary of all the accounts.
My problem is that I need each of these 'accounts', per say, need to be named after the user ID's that are generated.
So for example, the user ID created for someone is "Jo23219" and their 'account' is a dictionary:
account = {
"user": "Jo23219",
"pass": "password",
"status": "silver",
}
But instead of the dictionary being named "account", I need it named "Jo23219".
I understand this question has been asked before, but they have been answered with the use of dictionaries or lists, which would be fairly inconvenient for what I'm trying to achieve.
Is it possible to do this without dictionaries or lists?
What you want is a dictionary of dictionaries, e.g.
dct = {
"Jo23219": {
"user": "Jo23219",
"pass": "password",
"status": "silver"
},
"John": {
"user": "John",
"pass": "password",
"status": "gold"
}
}
Then you can access the credentials of the userID, say Jo23219
you want to as follows
print(dct['Jo23219'])
#{'user': 'Jo23219', 'pass': 'password', 'status': 'silver'}