dict
sampleDict = { "class": { "student": { "name": "Mike", "marks": { "physics": 70, "history": 80 } } } }
Expected output:
80
Hint:
It is a nested dict. Use the correct chaining of keys to locate the specified key-value pair.
Solution:
sampleDict = { "class": { "student": { "name": "Mike", "marks": { "physics": 70, "history": 80 } } } } # understand how to located the nested key # sampleDict['class'] = {'student': {'name': 'Mike', 'marks': {'physics': 70, 'history': 80}}} # sampleDict['class']['student'] = {'name': 'Mike', 'marks': {'physics': 70, 'history': 80}} # sampleDict['class']['student']['marks'] = {'physics': 70, 'history': 80} # solution print(sampleDict['class']['student']['marks']['history'])
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Hint:
It is a nested dict. Use the correct chaining of keys to locate the specified key-value pair.
Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer