This is the code I wrote in order to find the smallest value in a list using recursion.However I feel like there would be a better way to do this?
def minimum(lst):
"""
parameters : lst of type list
return : the value of the smallest element in the lst
"""
if len(lst) == 1:
return lst[0]
if lst[0] < lst[1]:
lst.append(lst[0])
return(minimum(lst[1:]))
else:
return(minimum(lst[1:]))
min
;) I added the recursion and reinventing-the-wheel tags. \$\endgroup\$