6-1
dict = {'first_name':'cao','last_name':'wenhua','age':21,'city':'guangzhou'} print(repr(dict['first_name'])) print(repr(dict['last_name'])) print(repr(dict['age'])) print(repr(dict['city']))6-5
river = {'china':'Yangtze','Egypt':'nile'} print('the '+ river["china"] + ' runs through china') print('the '+ river["Egypt"] + ' runs through Egypt')6-8
mydog = {'host':'joke','type':'dog'} mycat ={'host':'alice','type':'cat'} myfish = {'host':'bob','type':'fish'} list = [mycat,mydog,myfish] for x in list : print(x['host']+ ' has a '+ x['type'])6-11
beijing = {'country':'china','population':10000000,'fact':'the capital of china'} newyork = {'country':'America','population':8000000,'fact':'the biggest metropolitan in the world'} tokye = {'country':'japan','population':9000000,'fact':'the capital of japan'} cities = [beijing,newyork,tokye] for x in cities: print(x["country"] +' has a city which has '+str(x["population"])+' and is '+ x["fact"])