Hi! So I was revising the code for the Max Value algoritm I built for my algoritms practice and I decided to replace a fixed list of numbers with an input().split(), so now the algoritm stops at a random place in the list and returns a random value from the list instead of max value. And I don’t understand what might be an issue. Can someone help please?
a = input().split()
print(f"\nCurrent list of values:", a)
def maxval(a):
"""Function that returns biggest value the array"""
mx = a[0]
max_in = 0
print(f"Current max: {mx}, at index {[0]}")
for i in range(0,len(a)):
print(f"Cheking number: {a[i]}, at index:",[i])
if a[i] > mx:
mx = a[i]
max_in = i
return mx, max_in
print(f"\nNew biggest max value:",maxval(a))
Before this issue occured the only difference in the code was:
a = [2,4,6,10,2,7,9,12,1,5]
and now it’s: a = input().split()
Thank you for your time and suggestions.
