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

19th Nov 2022, 11:10 PM
Maxim Prontenko
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
20th Nov 2022, 7:03 AM
Oma Falk
Oma Falk - avatar
+ 1
Take a look at unicode characters and their values
19th Nov 2022, 11:56 PM
Aggelos M
Aggelos M - avatar
+ 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'))
20th Nov 2022, 11:54 AM
Solo
Solo - avatar
0
Thanks guys for help) Good luck in everything)
20th Nov 2022, 9:43 PM
Maxim Prontenko