Python: Finding the last index of min element?

前端 未结 6 453
情书的邮戳
情书的邮戳 2021-01-12 05:20

For example [1,2,3,4,1,2]

has min element 1, but it occurs for the last time at index 4.

6条回答
  •  伪装坚强ぢ
    2021-01-12 05:22

    len(list_) - list_[::-1].index(min(list_)) - 1

    Get the length of the list, subtract from that the index of the min of the list in the reversed list, and then subtract 1.

提交回复
热议问题