Dictionaries within dictionaries#
states = {"California" : {"population" : 39512223, "capital" : "Sacramento", "landlocked" : False},
"Oregon" : {"population" : 4217737, "capital" : "Salem", "landlocked" : False},
"Nevada" : {"population" : 3080156, "capital" : "Carson City", "landlocked" : True}}
Let’s get a bit of practice. Using the states
dictionary above, give the output for each code snippet.
In case of a KeyError, give the key that was missing, i.e., KeyError: 'foo'
.