0

How 'hello' is greater than 'good bye' in python??

Python

15th Nov 2019, 5:43 AM
Prashant Shokeen
Prashant Shokeen - avatar
4 Answers
+ 3
It's based on alphabet order. The letter "h" is after "g" so it's bigger. If you rather be more accurate, it's actually based on their unicode. Python compares the result of ord() for each first character of strings. If they were equal, it compares the result for second characters and it happens until some characters aren't equal. I n here hello is bigger than 'good bye' because ord('h')=104 and ord('g')=103.
15th Nov 2019, 6:48 AM
ΛM!N
ΛM!N - avatar
+ 1
most likely due to the fact that the words are compared letter by letter and as a result, these letters in the code table are more important
15th Nov 2019, 5:56 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
'Hello world!' is greatest
15th Nov 2019, 5:46 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
How
15th Nov 2019, 5:48 AM
Prashant Shokeen
Prashant Shokeen - avatar