Python code:
print(max(['2020','4','70','5']))
I am getting the output as 70
I want to understand how max()
works on strings.
Can anyone explain?
Python code:
print(max(['2020','4','70','5']))
I am getting the output as 70
I want to understand how max()
works on strings.
Can anyone explain?
max() can be used in 2 ways
max(iterable, *iterables, key, default)
number = [3, 2, 8, 5, 10, 6]
largest_number = max(number);
I think that what you want is this last one. If you also added a
print(largest_number)
It would throw you the output of 10
.
if you provide max()
a string
, it returns the highest alphabetical character in a string. So it will order based on alphabetical order descending.