0

I used the following function to return the maximum value index is the list:

def explicit(l):
'''This function returns the index of the largest item in the list'''
max_val = max(l)
max_idx = l.index(max_val)
return max_idx

However, the function seems not working if there are two maximum values.

How can I achieve that?

Kevin Ling
  • 540
  • 2
  • 7
  • 15
  • What doesn't work about it? And what do you want it to do if there is more than one maximum value? Return all the indices? – Bathsheba Feb 06 '17 at 12:13
  • 2
    Possible duplicate of [How to find the max number(s) in a list with tied numbers](http://stackoverflow.com/questions/21861730/how-to-find-the-max-numbers-in-a-list-with-tied-numbers) – Chris_Rands Feb 06 '17 at 12:13
  • Actually, the well-spotted dupe has it. – Bathsheba Feb 06 '17 at 12:14

0 Answers0