I was working on a project where I had to find the position of the smallest number in a list.
At first, I thought it would be simple. But then I realized there are multiple ways to do this in Python, each with its own advantages.
In this tutorial, I’ll show you five simple methods I use to get the index of the minimum element in a Python list. I’ll also share complete code examples so you can try them directly in your projects.
Method 1: Use Python List index() Function
The index() function is another built-in function in Python specifically used for finding the index of the first occurrence of a given value in a sequence.
Here is the full code:
marks = [100, 67, 88, 29, 33, 74]
result = marks.index(min(marks))
print("Minimum index position:",result)Output:
marks = [100, 67, 88, 29, 33, 74]
result = marks.index(min(marks))
print("Minimum index position:",result) We can combine this with the min() function to get the last index of the minimum element of the list in Python.
Method 2: Use min() and Lambda Function
This is another approach to get the index of the minimum element of a list in Python using lambda functions.
def find_min_index(list):
minimum_index = min(range(len(list)), key=lambda i: list[i])
return minimum_index
price_list = [5, 2, 9, 1, 7]
minimum_index = find_min_index(price_list)
print("The minimum index present at:", minimum_index)This line of Python code finds the index of the minimum value in the list using the min function along with the range function to iterate over indices and a lambda function to determine the key for comparison.
minimum_index = min(range(len(list)), key=lambda i: list[i])Output:
The minimum index present at: 3You can refer to the screenshot below to see the output.

In Python, the lambda functions are similar to user-defined functions but without a name. They are commonly referred to as anonymous functions.
Method 3: Use Python’s enumerate() Function
In Python, the enumerate() function takes an input as an iterable, adds a counter to each iterable element, and returns an enumerate object. The counter can also act as an index to each element, which can be used as an element.
def get_min_index(list):
minimum_value = min(list)
for index, value in enumerate(list):
if value == minimum_value:
return index
temperatures = [55, 36, 42, 35, 68, 45]
minimum_index = get_min_index(temperatures)
print("The minimum index position from the list:", minimum_index)Here, this function calculates the minimum value in the given list using the min() function, then iterates over the elements and indices of the list using enumerate().
def get_min_index(list):
minimum_value = min(list)
for index, value in enumerate(list):
if value == minimum_value:Output:
The minimum index position from the list: 3You can refer to the screenshot below to see the output.

Within the loop, it compares each value with the minimum value and returns the index if it matches.
Method 4: Use Python’s sorted() Function
We can use the enumerate() in Python to get tuples of (index, value) pairs, then sort these pairs based on the values using the sorted() function with a custom key function.
def get_min_index(list):
sorted_list = sorted(enumerate(list), key=lambda x: x[1])
min_index = sorted_list[0][0]
return min_index
input_list = [21, 7, 15, 2, 11, 0]
output_index = get_min_index(input_list)
print("The minimum index present is:",output_index)Output:
The minimum index present is: 5You can refer to the screenshot below to see the output.

Finally, the function will return the index of the first element in the sorted list of indices, corresponding to the index of the minimum element in the original list in Python.
Method 5: Use a for loop
This is another way to get the index of the minimum element of the list in Python using a for loop.
input_number_list = [62, 31, 20, 88, 49, 12, 120]
minimum_value= input_number_list[0]
for i in range(1, len(input_number_list)):
if (input_number_list[i] < minimum_value):
minimum_value = input_number_list[i]
result = input_number_list.index(minimum_value)
print("Minimum Value:",minimum_value)
print("Minimum Index position:",result)These lines of Python code iterate over the list indices starting from 1. Then, it compares each element with the minimum value, updates if a smaller value is found, and retrieves the index of the value using the index() method.
for i in range(1, len(input_number_list)):
if (input_number_list[i] < minimum_value):
minimum_value = input_number_list[i]
result = input_number_list.index(minimum_value)Output:
Minimum Value: 12
Minimum Index position: 5You can refer to the screenshot below to see the output.

This method uses a for loop to manually find the smallest element in the list and then retrieves its index using the index() method.
Method 6: Use min() and itemgetter() Functions in Python
We can get the index of the minimum element of a list in Python using the min() and itemgetter() functions.
from operator import itemgetter
number_list = [18, 16, 19, 11, 12, 10]
result = min(enumerate(number_list), key=itemgetter(1))[0]
print("Index of minimum value is:",result) Output:
Index of minimum value is: 5You can refer to the screenshot below to see the output.

In Python, the itemgetter() function from the operator module returns a callable object and can get some element from its operand.
Conclusion
In this Python article, the information provided gives you a clearer picture of how to get the index of the minimum element of a list in Python.
Additionally, I have covered different ways to get the index of the minimum element of a list in Python, such as using min() with index(), min() with lambda(), min() and enumerate(), using sorted(), for loop, and min() and itemgetter().
By understanding these methods, developers can choose according to their needs.
You may also like to read these articles:
- Use Static Variables in Python Functions
- Difference Between Class and Instance Variables in Python
- Insert a Python Variable into a String
- Write a Variable to a File in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.