在为完成练习6-1而编写的程序中,再创建两个表示人的字典,然后将这三个字典都存储在一个名为people 的列表中。遍历这个列表,将其中每个人的所有 信息都打印出来。
friend_0 = {'first_name': 'xiao ming', 'last_name': 'zhang', 'age': 19, 'city': 'cheng du'}
friend_1 = {'first_name': 'xiao hong', 'last_name': 'zhang', 'age': 21, 'city': 'luo yang'}
friend_2 = {'first_name': 'hua', 'last_name': 'li', 'age': 18, 'city': 'xi an'}
people = [friend_0, friend_1, friend_2]
for friend in people:
full_name = friend['last_name']+' '+friend['first_name']
age = friend['age']
city = friend['city']
print(full_name.title()+":")
print("\t"+str(age))
print("\t"+city)
print("\n")