-1
print('a'>'A')

why it shows "True" result what is the logic??

1 Answers1

2

Look up the ordinals for these characters -- the position in the ASCII or Unicode table for each character or code point:

>>> ord('a')
97
>>> ord('A')
65
>>> print('a'>'A')
True

97 is greater than 65. Thus, a comes after A.

See Sort dictionary by key using locale/collation for discussion of how comparison can be done according to locale-specific collation order instead.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441