25th Jun 2020, 3:29 PM
Teja Swaroop
Teja Swaroop - avatar
5 Antworten
+ 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
25th Jun 2020, 3:36 PM
uday kiran
uday kiran - avatar
+ 6
Teja Swaroop, please read the post from uday kiran. He has given an excellent description how it works.
25th Jun 2020, 5:17 PM
Lothar
Lothar - avatar
+ 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
25th Jun 2020, 3:36 PM
ycsvenom
ycsvenom - avatar
+ 1
Because it's compare between two strings And "4" is bigger than 2 So it choose "4" as bigger
25th Jun 2020, 3:33 PM
ycsvenom
ycsvenom - avatar
+ 1
It will consider only first character in string? Or any logic based on ASCII values?
25th Jun 2020, 3:35 PM
Teja Swaroop
Teja Swaroop - avatar