# any list a = [1, 7, 3, 12, 5] # index of minimum element # if more than 1 minimum, # first index is returned min_index = a.index(min(a)) # index of maximum element max_index = a.index(max(a))
Here is what the above code is Doing:
1. We create a list a with some elements.
2. We find the minimum element in the list and store it in min_index.
3. We find the maximum element in the list and store it in max_index.