Mega Code Archive

 
Categories / Python Tutorial / String
 

Cmp() function performs a lexicographic (ASCII value-based) comparison for strings

str1 = 'abc' str2 = 'lmn' str3 = 'xyz' print cmp(str1, str2) print cmp(str3, str1) print cmp(str2, 'lmn')