How am I supposed to extract the value 1234
from "password"
?
account = {
'Dicky': {
'password': 1234,
'balance': {
'USD': 10,
'HKD': 10000
}
}
}
How am I supposed to extract the value 1234
from "password"
?
account = {
'Dicky': {
'password': 1234,
'balance': {
'USD': 10,
'HKD': 10000
}
}
}
to extract values form dict:
dict["key"]
so in your case because there is a nested dict:
dict["1stkey"]["2ndkey"]
so:
account["Dicky"]["password"]
In Python, a nested dictionary is a dictionary inside a dictionary. example:
nested_dict = { 'dictA': {'key_1': 'value_1'},
'dictB': {'key_2': 'value_2'}}
so:
nested_dict['dict1']['key_A']--->'value_A'
this question
account = {
'Dicky': {
'password': 1234,
'balance': {
'USD': 10,
'HKD': 10000
}
}
}
account["Dicky"]["password"]
print(account["Dicky"]["password"])
1234