-3

print('a'>'b') Returns False similar to this print('a'>'A') Returns True

2 Answers2

4

Python uses Lexicographical ordering for strings. This means that it uses the Unicode point number to order characters.

Reference: https://docs.python.org/3/tutorial/datastructures.html#comparing-sequences-and-other-types

You may find this useful: https://en.wikipedia.org/wiki/List_of_Unicode_characters

Sxribe
  • 819
  • 7
  • 16
0

Python 3 uses unicode

Each character has a value according to the ASCII table:

https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html

'a' = 97

'b' = 98

'A' = 65

Which is why 97 > 98 returns false

Almog
  • 29
  • 4