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:

Activity: CodeLens 7.8.2 (strComparisonCodelens)

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.

You have attempted of activities on this page