example #1
numbers = ['1086', '1123', '543', '1180', '1222', '1300', '888']
print(max(numbers))
result: 888,
desired result: 1300
example #2
numbers = ['1086', '1123', '1180', '1222', '1300']
print(max(numbers))
result: 1300,
desired result: 1300
goal
numbers = ['1086', '1123', '543', '1180', '1222', '1300', '888']
print(max(numbers))
result: 1300,
desired result: 1300
all 3 digit and 4 digit combinations should be involved
first 10 results from google index, that offering "enumarate", "max()", "sort()", [-1], [0] also different variations of "for" etc..
got me to write this question.
at most brain dead copy/paste.
thanks!
>Solution :
You list contains string not integers, you make use of map() to convert the string to integers:
numbers = ['1086', '1123', '543', '1180', '1222', '1300', '888']
print(max(map(int, numbers)))
>>> 1300