+ 3

print(max("SoloLearn"))

Anyone can explain this for me? Why the solution is r?

4th Dec 2021, 6:30 AM
Hamid
4 Answers
+ 9
Here, max() function compares each character in the string lexicographically. The comparison is done based on each character's ASCII value (or Unicode value if it was a Unicode character). But the string "SoloLearn" contains no Unicode character. See the following dictionary to understand how letter 'r' was considered as maximum (greatest) member of the string. print( { letter : ord( letter ) for letter in "SoloLearn" } )
4th Dec 2021, 6:56 AM
Ipang
+ 4
There's a table we can refer to, here ... https://www.asciitable.com/mobile/
4th Dec 2021, 7:39 AM
Ipang
+ 3
Thank you very much, so can I conclusion big letters have fewer value than small latters? a > Z , a < z
4th Dec 2021, 7:23 AM
Hamid
+ 2
😊🙏
4th Dec 2021, 7:43 AM
Hamid