def minimum(x):
mini = x[0]
for i in x[0:]:
if i < mini:
mini = i
else:
mini = x[0]
return (mini)
b = [1,2,3,4,5]
c= [3,6,2,7,9]
print minimum(b)
print minimum(c)
My code works for the first list (b) that I used to test (it returns 1 as the minimum), but for the second list (c) it returns (3) and I can't figure out why. Thanks!
:edit: Just figured it out, removing the "else" portion of the for loop fixed the problem