Compare the two string based on ascii values

str1=raw_input('Enter the string 1:  ')
str2=raw_input('Enter the string 2:  ')
if str1==str2:
      print 'String are equal'  # It is working based on ascii value  refer http://www.ascii-code.com/
elif str1<str2:
      print 'Str2 is greater than str1'
elif str1>str2:
        print 'Str1 is greater than str2'
elif str1<=str2:
        print 'Str1 is greater than or equal to str2'
elif str1>=str2:
        print 'Str1 is greater than or equal to str2'
elif str1!=str2:
        print 'Str1 is not equal to str2'

No comments: