Request for argmax(list) and argmin(list)
ABCCDE921
atharvasakhala5445 at gmail.com
Wed Sep 1 03:20:18 EDT 2021
Because that does 2 passes over the entire array when you only need one and there is no option to specify if you want the leftmost or rightmost element
On Wednesday, September 1, 2021 at 12:02:29 PM UTC+5:30, Paul Bryan wrote:
> Why not:
>
> >>> l = [1, 3, 5, 9, 2, 7]
> >>> l.index(max(l))
> 3
> >>> l.index(min(l))
> 0
> On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> > I dont want to import numpy
> >
> > argmax(list)
> > returns index of (left most) max element
> >
> > argmin(list)
> > returns index of (left most) min element
More information about the Python-list
mailing list