Files
30-seconds-of-code/snippets/min_element_index.md
2020-10-06 01:02:00 +05:30

352 B

title, tags
title tags
min_element_index list,beginner

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(array):
  return array.index(min(array))
min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2