i am writing my program to find the minimum value from the given elements in a list. But the minValue variable is printing 5 and not 0. why it is printing 5 and why not 0 ? In my given list minimum value is 0 so this program should print 0. i am facing problem in line 8 and 9 where nextValue is assigned to minValue but in real it is not working.
a = [5,0,4,1,3,2]
def minimumElement(n):
minValue = a[0]
i =1
while i < n:
nextValue = a[i]
if minValue > nextValue:
minvalue = nextValue
print(minValue)
i+=1
minimumElement(6)
output is coming
5
5
5
5
5
output i want
0
Shailendra Singh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.