+ 1

If a word is much longer than the other, does it matter?

e.g print("autos" > "automovilismo") True or False?

10th Sep 2020, 12:28 PM
Lucas Piputto
Lucas Piputto - avatar
3 ответов
+ 7
Strings are compared lexically, like you'd find them in a dictionary. Letter by letter will be compared, until a 'greater' one is found. (Something is greater than nothing.) Otherwise equal. So... ab > aaa: True, because b>a. What happens after second letter doesn't matter anymore. So in your example, after 5th letter, the test is already over, because s>m.
10th Sep 2020, 12:39 PM
HonFu
HonFu - avatar
+ 2
If you want the length to matter prefer the len function: len("autos") > len("automovilismo")
10th Sep 2020, 1:30 PM
Seb TheS
Seb TheS - avatar
+ 1
Thank you both so much
10th Sep 2020, 1:33 PM
Lucas Piputto
Lucas Piputto - avatar