0
Help pls!
I don't understand how string comparison works. Let's say "a" is the first in the alphabet (a=1), and b is the second (b=2), I add them x = "a"; x += âbâ, and compare x < or x > âgâ (g is the seventh in the alphabet g=7), then x will be less than g, because a(1)+b(2)=3 or more, because that âaâ + âbâ= â1â+â2â=12? https://code.sololearn.com/cHJEr7rW8Edt/?ref=app https://code.sololearn.com/cGCVAdD5klpL/?ref=app
4 Answers
+ 2
It is lexicographical order.
"abvf" < all strings beginning with b,c,d,.....
also < all strings beginning with ac, ad, ae.......
....
also < all strings beginning with abvf but being longer
+ 1
Take a look at unicode characters and their values
+ 1
No, the strings are compared character-by-character, (each character separately to each other depending on the location in the string.
That is, when comparing "ab" with "g", only "a" and "g" are compared.
print(ord('a'),ord('b'),ord('g'))
0
Thanks guys for help) Good luck in everything)