The problem is you’re comparing strings and not numbers, so when you compare "10" to "3" the first is smaller, because analysis is done character by character, then the comparison is character "1" to character "3", and of course "3" is larger. This does not work, and to function as you will have to do strings in int
s.
But there is a problem, you cannot guarantee that all items can be converted. You will have to deal with the exception that will be generated by transforming the entire text, so the code gets a little more complicated.
a = 'joao 1 0 10 2 3'
b = a.split()
c = []
for i in b:
try:
c.append(int(i))
except ValueError:
pass
print(max(c))
print(min(c))
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
Obviously the question does not make clear what to do with the strings, I had the understanding that should ignore and not generate error, after all the code would not be useful, and would not give the result that the AP asked in the question with input data, and I considered that the cited example of input is only to facilitate, that might or might not have texts even in the middle of the numbers in any position.
It must be because the list is like
string
you’re gonna have to do something likeb = list(map(int, b))
to convert toint
– Icaro Martins