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

 from operator import itemgetter
 index, element = max(enumerate(items), key=itemgetter(1))

Return the index of the biggest element in items and the element itself.


This method finds the index of the maximum element of any iterable and does not require any external imports:

def argmax(iterable):
    return max(enumerate(iterable), key=lambda x: x[1])[0]

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.