Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python min and max functions, but with indices

Does Python have a built-in function like min() and max() except that it returns the index rather than the item?

like image 920
Sylvester V Lowell Avatar asked May 17 '26 02:05

Sylvester V Lowell


1 Answers

There is no inbuilt function for that. You can just do your_list.index(min(your_list)).

like image 131
Russell Dias Avatar answered May 19 '26 15:05

Russell Dias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!