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
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
I think its using Lexicographical order http://en.wikipedia.org/wiki/Lexicographical_order
"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.