python 自定义一个数字列表,求列表中第二大数的下标

直接上,冲冲冲
#自定义一个数字列表,求列表中第二大数的下标
# ages = [1, 2, 15, 4, 11, 12, 19, 8, 20, 18]
# max1 = 0
# max2 = 0
# for i in range(len(ages)):
#     if ages[i] > ages[max1]:
#         max2 = max1
#         max1 = i
#     elif ages[i] > ages[max2]:
#         max2 = i
# print(max2)
#

  

posted @ 2020-11-07 11:48  全村的唯一希望  阅读(616)  评论(0编辑  收藏  举报