Finding the index of the value which is the min or max in Python

前端 未结 8 702
深忆病人
深忆病人 2020-12-30 21:26

I\'ve got a structure of the form:

>>> items
[([[0, 1], [2, 20]], \'zz\', \'\'), ([[1, 3], [5, 29], [50, 500]], \'a\', \'b\')]

The

8条回答
  •  一个人的身影
    2020-12-30 22:13

    Yet another way to get the argmax is:

    def argmax(lst):
        return max(range(len(lst)), key=lst.__getitem__)
    

提交回复
热议问题