一个简单的学习示例

bob = ['Bob Smith', 42, 30000, 'software']
sue = ['Sue Jones', 45, 40000, 'hardware']

print(bob[0], sue[2])

print("\n")

print(bob[0].split()[-1])

sue[2] *= 1.25

print("\n")

print(sue)

people = [bob, sue]
for person in people:
 print(person)
#for语句里面要有缩进

print("\n")
print(people[1][0])

print("\n")

for person in people:
 print(person[0].split()[-1]) # print last names

 person[2] *= 1.20 # give each a 20% raise

 print(person[2])


运行结果如下所示:


一个简单的学习示例_第1张图片



你可能感兴趣的:(each)