Files
30-seconds-of-code/snippets/min-element-index.md
Angelos Chalaris f6a215e9e3 Kebab file names
2023-04-27 22:00:06 +03:00

440 B

title, tags, cover, firstSeen, lastUpdated
title tags cover firstSeen lastUpdated
Index of min element math,list two-cities 2020-10-05T22:32:00+03:00 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.
def min_element_index(arr):
  return arr.index(min(arr))
min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2