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 Respuestas
+ 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)