Is there a simple way to find the list index to the max value?

Aahz aahz at
Tue Feb 16 20:44:45 CET 2010

In article <4B7A91B1.6030301 at>, steve  <steve at> wrote:
>On 02/16/2010 05:49 PM, W. eWatson wrote:
>> See Subject. a = [1,4,9,3]. Find max, 9, then index to it, 2.
>The most obvious would be a.index(max(a)). Is that what you wanted ?

The disadvantage of that is that it's O(2N) instead of O(N).
Aahz (aahz at           <*>

"At Resolver we've found it useful to short-circuit any doubt and just        
refer to comments in code as 'lies'. :-)"

More information about the Python-list mailing list