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
  • 1,048,767
  • 296
  • 4,058
  • 3,343

2 Answers2

0

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

user2184057
  • 924
  • 10
  • 27
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
  • 178,883
  • 35
  • 278
  • 309