One string more than another (>)

Hello in the Complete Python Mastery Course, in Section 3 - Control Flow, Episode 7 - Quiz, there is a comparison between “bag” > “apple” and “bag” > “cat”. From a previous episode, I remembered that “bag” > “apple” is True. However, I do not know how to tell that “cat” comes after “bag”.
Additionally, since each character is tied to a number in python, how does it calculate the total? Is it a summation of all the numbers tied to the characters in the string that python then uses to calculate the expression?


cat > bag
using ASCII get the value of c & b in lowercase we get 99 & 98
so 99 > 98 which is True

1 Like

Ohh ok so it compares using the first letter. I forgot about the table so was super confused. Thank you!