# 6-5
rivers_countrys = {'nile': 'egypt', 'yellow river': 'china', 'the ganges river': 'india'}
for river, country in rivers_countrys.items():
print(river.title() + " flows through " + country.title())
for river in rivers_countrys.keys():
print(river.title())
for country in rivers_countrys.values():
print(country.title())
# 6-6
favorite_languages = {
'lilongbin': 'java',
'zhaohaibing': 'c',
'jian': 'python',
}
peoples = ['lilongbin', 'zhaohaibing', 'jian', 'taohuaxian', 'zhudi']
for people in peoples:
if people in favorite_languages.keys():
print("Hi " + people.title() + ".Thank you for participating in the survey!")
else:
print("Hi " + people.title() + ".Can you accept our investigation?")
Nile flows through Egypt
Yellow River flows through China
The Ganges River flows through India
Nile
Yellow River
The Ganges River
Egypt
China
India
Hi Lilongbin.Thank you for participating in the survey!
Hi Zhaohaibing.Thank you for participating in the survey!
Hi Jian.Thank you for participating in the survey!
Hi Taohuaxian.Can you accept our investigation?
Hi Zhudi.Can you accept our investigation?
网友评论