学习编程的过程,我感受的是思考的分层,学习是一层一层递进的。
列表:L = ['A','B','C','D']
names = ['小赵','小钱','小孙','小李','小王','小张']
friends = [45, 100, 67, 136, 77, 17]
maxName = None
maxFriend = None
for friend in friends:
if maxFriend is None or maxFriend < friend:
maxFriend = friend
index = friends.index(maxFriend)
maxName = names[index]
print(maxName,"的朋友竟然有",maxFriend)
要点:maxName = names[index],通过取读最大朋友数的序列,获取maxName.
maxFriend = max(friends)
maxName = names[friends.index(maxFriend)]
print(maxName,"的朋友竟然有",maxFriend)
要点:maxName =names[friesnds.index(maxFriend)],关键是【】,列表使用【】。