Max function question: How do I return the index of the maximum value of a list?

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Sun Jun 4 18:21:21 EDT 2006


jj_frap enlightened us with:
> When I try to print the "winner" (I've not coded for kicker strength
> and ties yet) via the max function, it returns the maximum value in
> the list rather than the index associated with that value.
>
> How do I return the index?

You can't even be sure it exists - there might be multiple maximum
values. What would you expect in such a case?

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list