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

gene tani gene.tani at gmail.com
Sun Jun 4 18:29:38 EDT 2006


jj_frap wrote:
> I'm new to programming in Python and am currently writing a three-card
> poker simulator. I have completed the entire simulator other than
> determining who has the best hand (which will be far more difficult
> than the aspects I've codes thus far)...I store each player's hand in a
> list of hand objects and I determine hand strength via a handstrength
> list with one element for each player.
>
> 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?

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/306862
http://www.rubyquiz.com/quiz24.html




More information about the Python-list mailing list