bob = {'age' : 26 , 'fullname' : 'Bob Dwayne Lee' , 'status' : 'married'}
name = input('whats your name? ') #user input is bob
print (name['age'])
TypeError: string indices must be integers
bob = {'age' : 26 , 'fullname' : 'Bob Dwayne Lee' , 'status' : 'married'}
name = input('whats your name? ') #user input is bob
print (name['age'])
TypeError: string indices must be integers
You wouldn't.
Instead, you would make a variable that stores all your record by their own key, and lookup into that:
all_users = {
'bob': { 'age': 26 , 'fullname': 'Bob Dwayne Lee' , 'status': 'married'}
}
name = input('whats your name? ') #user input is bob
print(all_users[name]['age'])