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 > > But it seems like something that should be built in - or at least I should > be able to write a lambda function for it, but I'm not sure how to do that > either...Suggestions are very much welcome! >
I really think this is a good candidate for a builtin. I suggest: max2 (x): """ return (minvalue,minindex)""" This allows efficient usage in all cases, including iterators (not just sequences). -- http://mail.python.org/mailman/listinfo/python-list