6-5 河流:创建一个字典,在其中存储三条大河流及其流经的国家。其中一个键—值对可能是'nile': 'egypt'。
·使用循环为每条河流打印一条消息,如“The Nile runs through Egypt.”。
·使用循环将该字典中每条河流的名字都打印出来。
·使用循环将该字典包含的每个国家的名字都打印出来。
river={'nile':'egypt','amazon':'America','Yangtze':'China'}
for rive in river.keys(): #如果这里使用river而不是rive(别的也可以),下个循环就出问题了
print(rive.title())
for city in river.values():
print(city.title())
for k,v in river.items():
print('The '+k.title()+' runs through '+v.title()+'.')
运行结果: