【发布时间】:2021-03-30 20:04:36
【问题描述】:
我想打印出列表中最大数的第 n 个值
list_= [1,3,2,2,8,11,4]
max_val = max(list_)
预期输出
The maximum value of 11 is at the 6th place from the start of the order
【问题讨论】:
-
查看
index方法。 -
list_.index(max(list_))index =>list_.index(max(list_)) + 1th place. -
index不必要地循环列表两次。请参阅链接帖子上的答案以获得更快的答案。 -
@Aplet123 @Escualo 在给定链接中的回答似乎表明
index的显式使用即使不是更快也一样快。
标签: python python-3.x list max