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

4th May 2020, 2:22 AM
Casc
Casc - avatar
11 Answers
4th May 2020, 2:43 AM
Casc
Casc - avatar
+ 1
๐Š๐ข๐ข๐›๐จ ๐†๐ก๐š๐ฒ๐š๐ฅ yeah it works, thank you. Can you please explain why did you โ€˜+ indexโ€™ in the return ???
4th May 2020, 3:50 AM
Casc
Casc - avatar
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
4th May 2020, 2:25 AM
Casc
Casc - avatar