0

What argument is considered in this scenario?

a = "ABba"
b = "abBA"
if(a<b):
    print("a<b")
elif(a==b):
    print("a=b")
elif(a>b):
    print("a>b")

Which gives:

a<b
Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187

2 Answers2

0

I think its using Lexicographical order http://en.wikipedia.org/wiki/Lexicographical_order

user2184057
  • 801
  • 10
  • 26
0

"A", character 65, is less than "a", character 97, because 65 < 97. The comparison of the two strings need not progress beyond the first character.

If you wish a case-insensitive comparison, convert them to a consistent case first:

if a.upper() < b.upper():
    # etc.
kindall
  • 168,929
  • 32
  • 262
  • 294