0
Find the minimum (python)
Implement a function find min(lst, index) that takes a list of orderable items and an index as input. The function returns the index of the smallest item in lst[index:]. If there are duplicate values, then the function returns the smaller index. # Example : >>> find_min ([ ' candlestick ', 'pipe ', 'rope ', 'knife ', 'wrench '] , 2) 3 >>> find_min ([1 , 3 , 5 , 11 , 7 , 3 , 2 , 6 , 2] , 3) 6 My attempt is in the comment https://code.sololearn.com/c369wAQs9rIp/?ref=app
6 Answers
+ 1
๐๐ข๐ข๐๐จ ๐๐ก๐๐ฒ๐๐ฅ sorry that was a typo.. but i still get 0 for the output
+ 1
๐๐ข๐ข๐๐จ ๐๐ก๐๐ฒ๐๐ฅ yeah it works, thank you.
Can you please explain why did you โ+ indexโ in the return ???
+ 1
๐๐ข๐ข๐๐จ ๐๐ก๐๐ฒ๐๐ฅ right, that makes sense. thank you :))
0
my attempt:
def find_min(lst, index):
lst1 = lst[index:]
min_lst1 = min(lst1)
lst2 = lst.index(min_lst1)
return lst2
>>>lst = [5,2,3,10,1,10,5,6,5,8,10]
>>> find_min(lst, 8)
0
instead of 0, how can i get 8? for the index num 5
0
Jay Matthews ๐๐ข๐ข๐๐จ ๐๐ก๐๐ฒ๐๐ฅ i posted my attempt in the comment above