Skip to content
This repository was archived by the owner on May 7, 2023. It is now read-only.

Latest commit

 

History

History
20 lines (16 loc) · 412 Bytes

max-element-index.md

File metadata and controls

20 lines (16 loc) · 412 Bytes
title type tags cover dateModified
Index of max element
snippet
math
list
dark-cloud
2020-11-02 19:28:27 +0200

Returns the index of the element with the maximum value in a list.

  • Use max() and list.index() to get the maximum value in the list and return its index.
def max_element_index(arr):
  return arr.index(max(arr))
max_element_index([5, 8, 9, 7, 10, 3, 0]) # 4