6-2最喜欢的数字
favorite_num={"Alice":18,"Bob":2,"Cindy":14,"David":23,"Ella":34}
for name,num in favorite_num.items():
print(name+"'s favorite number is "+str(num))
6-5河流
rivers={'nile':'egypt','yangtze river':'china','mississippi':'america'}
for river,country in rivers.items():
print('The '+river.title()+' runs through '+country.title()+'.')
for river in rivers.keys():
print(river.title())
for country in rivers.values():
print(country.title())
6-8宠物
Kat={'type':'rabbit','host':'Tommy'}
Cindy={'type':'cat','host':'June'}
Alice={'type':'fish','host':'Bob'}
pets=[Kat,Cindy,Alice]
for pet in pets:
print(pet)
6-10最喜欢的数字
favorite_num={"Alice":[18,23,56],"Bob":[2,80,99],"Cindy":[14],"David":[23,34],"Ella":[354,67]}
for name,num in favorite_num.items():
print(name+"'s favorite number is:")
for i in num:
print(i)