Python | Find Index of Maximum Number in List

Python’s List Object type is quite useful for storing data while dealing with Scientific Computations where large amount of data need to be processed. Anyway, in this article => I’ll discuss How to find index of Maximum Element in a Python List?

Now there can be two possible scenarios in which List have just Maximum Number once and other can be a situation where list have same maximum numbers twice. [16, 82, 9, 17, 72, 72, 60, 72] this list have Maximum Number = 72 three times, so for this list Python Program should return three index values 4, 5, 7. Similarly [7, 8, 19, 6, 1] list have Maximum Number = 19 just once, so for this list Python Program should return 2.

Quite Simple, Just need to write a Python Program which takes care of multiple occurrences of Maximum Number in List. Let’s get into Python Code now for Finding Maximum Number’s Index in a List.

# Python Program to Find Largest number indexes in List

# Define List
a_list = [8, 91, 28, 91, 2, 6]     

# Largest Number in Python List
largest_number = max(a_list)	   

indexes_of_largest_number = []

for i in range(len(a_list)):
	if a_list[i] == largest_number:
		indexes_of_largest_number.append(i)

print("Indexes of Minimum Number in Python List are => ", indexes_of_largest_number)

Output of Above Code

Indexes of Minimum Number in Python List are =>  [1, 3]
Comments to: Python | Find Index of Maximum Number in List

Your email address will not be published.