From a2ff06d3a68fea2cdf6ff13d0fdd6c094671edce Mon Sep 17 00:00:00 2001 From: AkshatBhat Date: Tue, 6 Oct 2020 01:02:00 +0530 Subject: [PATCH 1/2] Add min_element_index --- snippets/min_element_index.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 snippets/min_element_index.md diff --git a/snippets/min_element_index.md b/snippets/min_element_index.md new file mode 100644 index 000000000..dabbf7220 --- /dev/null +++ b/snippets/min_element_index.md @@ -0,0 +1,17 @@ +--- +title: min_element_index +tags: 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. + +```py +def min_element_index(array): + return array.index(min(array)) +``` + +```py +min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2 +``` \ No newline at end of file From 8fbb35612561654b5f6447b88aff44e52bcc4133 Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Mon, 5 Oct 2020 22:41:15 +0300 Subject: [PATCH 2/2] Update min_element_index.md --- snippets/min_element_index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/min_element_index.md b/snippets/min_element_index.md index dabbf7220..55aa63248 100644 --- a/snippets/min_element_index.md +++ b/snippets/min_element_index.md @@ -8,10 +8,10 @@ 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(array): - return array.index(min(array)) +def min_element_index(arr): + return arr.index(min(arr)) ``` ```py min_element_index([3, 5, 2, 6, 10, 7, 9]) # 2 -``` \ No newline at end of file +```