argmax

Max Erickson maxerickson at gmail.com
Thu Jun 1 17:29:46 CEST 2006


"David Isaac" <aisaac0 at verizon.net> wrote:

> 1. Why is there no argmax built-in?
> (This would return the index of the largest element in a
> sequence.) 
> 
> 2. Is this a good argmax (as long as I know the iterable is
> finite)? def argmax(iterable): return max(izip( iterable, count()
> ))[1] 
> 

use len:

len(iterable)-1


max





More information about the Python-list mailing list