题解 | #首都#
首都
http://www.nowcoder.com/practice/03a5031ed7ad4a7db897fd9ed982ea57
NP31 首都
思路:
注意如何取k和v;
代码如下:
cities_dict = {'Beijing': {'Capital': 'China'},'Moscow': {'Capital': 'Russia'},'Paris': {'Capital': 'France'}}
for k in sorted(cities_dict.keys()):
print('{} is the capital of {}!'.format(k,cities_dict[k]['Capital']))