6-7 人:在为完成练习6-1而编写的程序中,再创建两个表示人的字典,然后将这三个字典都
存储在一个名为people的列表中。遍历这个列表,将其中每个人的所有信息都打印出来。
marx={'first_name':'karl','last_name':'marx','age':'103','city':'landon'}
einstein={'first_name':'albert','last_name':'einstein','age':'142','city':'American'}
maozedon={'first_name':'mao','last_name':'zedon','age':'128','city':'hunan'}
people=[marx,einstein,maozedon]
print(people[0])
print(people[1])
print(people[2])
(用for遍历更为方便)
运行结果:
6-8 宠物:创建多个字典,对于每个字典,都使用一个宠物的名称来给它命名;在每个字典中,包含宠物的类型及其主人的名字。将这些字典存储在一个名为pets的列表中,再遍历该列表,并将宠物的所有信息都打印出来。
Tom={'type':'cat','monster':'awesome'}
Jerry={'type