How to get Index of Maximum and Minimum Value of a List in Python

Hi guys. In this tutorial we will learn about How to get Index of Maximum and Minimum Value of a List in Python. So here we are going to learn the methods which will be useful for to get the index of Maximum and Minimum Value of a List in Python. You can find the position of the maximum and minimum number in your list. So lets learn about of this methods. I hope these will help you.

How to get Index of Maximum and Minimum Value of a List in Python

  1. Get Index of Maximum and Minimum Value of a List in Python

    to get Index of Maximum and Minimum Value of a List in Python just Use max() and list.index(). To find out the index of Maximum Value of a List in Python you can use max() and list.index() functions. By using then you can find out the index of the maximum value in your list. So lets learn about of this method by given below example: mylist = [45,54,87,95,52] var1 = max(mylist) myindex = mylist.index(var1) print(myindex) Output : 3

  2. How to get Index of Maximum and Minimum Value of a List in Python

    to get Index of Maximum and Minimum Value of a List in Python just Use min() and list.index(). To find out the index of minimum Value of a List in Python you can use min() and list.index() functions. By using then you can find out the index of the minimum value in your list. For this first of all make your list and put min() function with it. And after that you can use list.index and you will get the min value's index. So lets learn about of this method by given below example: mylist = [45,54,87,95,52] var1 = min(mylist) myindex = mylist.index(var1) print(myindex) Output : 0

Method 1: Use max() and list.index()

To find out the index of Maximum Value of a List in Python you can use max() and list.index() functions. By using then you can find out the index of the maximum value in your list. So lets learn about of this method by given below example:

mylist = [45,54,87,95,52]
var1 = max(mylist)
myindex = mylist.index(var1)
print(myindex)

Output :

3

Method 2: Use min() and list.index()

To find out the index of minimum Value of a List in Python you can use min() and list.index() functions. By using then you can find out the index of the minimum value in your list. For this first of all make your list and put min() function with it. And after that you can use list.index and you will get the min value’s index. So lets learn about of this method by given below example:

mylist = [45,54,87,95,52]
var1 = min(mylist)
myindex = mylist.index(var1)
print(myindex)

Output :

0

Method 3: Use numpy.argmax()

By using numpy.argmax you can get the maximum value of your list. For this you have to import numpy first and then use this function with your list and you can find the index of the maximum value in your list. Lets learn this:

import numpy
mylist = [45,54,87,95,52]
myindex = numpy.argmax(mylist)
print(myindex)

Output :

3

Method 4: Use numpy.argmin()

You can use this method as like as above method. The difference is here you have to use numpy.argmin(). So lets learn it.

import numpy
mylist = [45,54,87,95,52]
myindex = numpy.argmin(mylist)
print(myindex)

Output :

0

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment