7.8. String comparison¶
The comparison operators work on strings. To see if two strings are equal:
Other comparison operations are useful for putting words in alphabetical order:
Python does not handle uppercase and lowercase letters the same way that people do. All uppercase letters come before all lowercase letters, so “Pineapple” is less than “banana”, even though “pineapple” is greater than “banana”.
A common way to address this problem is to convert strings to a standard format, such as all lowercase, before performing the comparison.