cmp() function performs a lexicographic (ASCII value-based) comparison for strings. : Compare String : String PYTHON TUTORIALS


PYTHON TUTORIALS » String » Compare 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')



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo String
» Compare String