Files
30-seconds-of-code/snippets/min_element_index.md
Isabelle Viktoria Maciohsek 19f636408c Make expertise a field
2022-03-01 20:27:27 +02:00

21 lines
442 B
Markdown

---
title: Index of min element
tags: math,list
expertise: beginner
firstSeen: 2020-10-05T22:32:00+03:00
lastUpdated: 2020-11-02T19:28:27+02:00
---
Returns the index of the element with the minimum value in a list.
- Use `min()` and `list.index()` to obtain the minimum value in the list and then return its index.
```py
def min_element_index(arr):
return arr.index(min(arr))
```
```py
min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2
```