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

前端 未结 8 688
深忆病人
深忆病人 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条回答
  •  萌比男神i
    2020-12-30 22:20

    The index of the max of a list:

    def argmax(lst):
      return lst.index(max(lst))
    

    If there are duplicate max values in lst, this will return the index of the first maximum value found.

提交回复
热议问题