Max Value Algoritm

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.

>>> '6' > '10'
True
>>> 6 > 10
False

Before, you had numbers like 2
Now you have textual strings like "2".
Python considers text strings compares lexicographically, so “6” is the “largest” in the first “letter”.

print(type(2)) #int
print(type("2")) #str

You probably want to use int(x) to convert the strings to integer numbers, something like a = [int(x) for x in input().split()].

Thank you so much, guys! I had a feeling it’s gonna be something related to strings and integers, but couln’t figure out what or how. Thanks!