0
Explain the logic please
5 Answers
+ 3
Two strings ,for both comparison will be done by indexing and from left to right till either of the strings length reached .
Max function will return which one is larger .
Coming to your code
print(max("2020","4"))
string1 = " 2020 "
string2 = " 4 "
As I said comparison starts from left to right string1[0] will be compared with string2[0]
Since ASCII value of 4 is greater than 2 so 4 will be returned by max function
+ 6
Teja Swaroop, please read the post from uday kiran. He has given an excellent description how it works.
+ 3
It's based on ASCII values
So if the first two characters are same then it will check the second two values and so on
+ 1
Because it's compare between two strings
And "4" is bigger than 2
So it choose "4" as bigger
+ 1
It will consider only first character in string? Or any logic based on ASCII values?