From fa7e45af143533c5e1007febe0677d3d7165a9aa Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Sun, 13 Mar 2022 23:34:18 -0400 Subject: [PATCH] [+] Prep9 min_index --- practice/prep9.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/practice/prep9.py b/practice/prep9.py index 548b512..76a17b7 100755 --- a/practice/prep9.py +++ b/practice/prep9.py @@ -84,8 +84,24 @@ def min_index(lst: list) -> int: >>> min_index([-10, 7, 3, 5]) 0 + >>> min_index([7, 7, 7, 7]) + 0 + >>> min_index([8, 7, 7, 7]) + 1 + >>> min_index([8, 7, 7, -1]) + 3 + >>> min_index([99999999]) + 0 """ - # TODO: implement this function + min = lst[0] + index = 0 + + for i in range(len(lst)): + if lst[i] < min: + min = lst[i] + index = i + + return index def min_index_sublist(lst: list, b: int, e: int) -> int: