How python is comparing these strings? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How python is comparing these strings?

"Apple">"Appl" And why "Apple" is greater than "Appl"?

12th Dec 2019, 1:06 PM
parag sahu
parag sahu - avatar
2 Answers
+ 4
Strings are compared letter by letter according to ASCII/Unicode. Something is 'larger' than nothing, so the extra letter will make the word larger. It's how you order words in dictionaries too.
12th Dec 2019, 1:17 PM
HonFu
HonFu - avatar
+ 1
HonFu thank u for the answer I got it.
12th Dec 2019, 1:26 PM
parag sahu
parag sahu - avatar