Index of maximum element in list

Henry Baxter henry.baxter at gmail.com
Sat Jan 26 00:19:42 CET 2008


Thanks Hexamorph and Neal. Somehow I didn't make the connection with using
'index', but I'm all sorted out now :)

On Jan 25, 2008 1:47 PM, Hexamorph <hexamorph at gmx.net> wrote:

> Henry Baxter wrote:
> > Oops, gmail has keyboard shortcuts apparently, to continue:
> >
> > def maxi(l):
> >     m = max(l)
> >     for i, v in enumerate(l):
> >         if m == v:
> >             return i
> >
>
> What's about l.index(max(l)) ?
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080125/c014b762/attachment.html>


More information about the Python-list mailing list