Returns the index of the element with the minimum value in a list.
- Use
min()
andlist.index()
to obtain the minimum value in the list and then return its index.
代码实现
def min_element_index(arr):
return arr.index(min(arr))
使用样例
min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2
翻译自:https://www.30secondsofcode.org/python/s/min-element-index