How does comparing strings of different lengths work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does comparing strings of different lengths work?

Why does print("abcd" > "abc") return True?

23rd Mar 2016, 9:34 PM
Davide Amato
Davide Amato - avatar
2 Answers
+ 2
It's the alphabetical order. "abcd" contains the "abc" plus the "d" so it is bigger than the "abc" and thus it returns as true. hope it helped a bit.
3rd Apr 2016, 3:48 PM
George Tavanidis
George Tavanidis - avatar
0
ascii of abcd>ascii of abc
6th Jul 2016, 6:16 PM
naveen panjala
naveen panjala - avatar