Case Sensitive Compare : Compare String « String « Python Tutorial






cmpStr = "abc"
upperStr = "ABC"
lowerStr = "abc"

print "Case Sensitive Compare"
if cmpStr == lowerStr:
    print lowerStr + " Matches " + cmpStr

if cmpStr == upperStr:
    print upperStr + " Matches " + cmpStr








5.4.Compare String
5.4.1.Strings are compared according to their order when sorted alphabetically:
5.4.2.To ignore the difference between uppercase and lowercase letters, use the string methods upper or lower
5.4.3.Case Sensitive Compare
5.4.4.Case In-Sensitive Compare
5.4.5.Compare string demo
5.4.6.cmp() function performs a lexicographic (ASCII value-based) comparison for strings.