|Python String Comparison|
Comparing StringsIt’s possible to compare strings just as you would numbers. Keep in mind, however, that Python is picky about strings being equal to each other. If the two strings differ, even slightly, they’re not considered the same.
Consider the following example:>>> a = "Virginia"
>>> b = "virginia"
>>> a == b False
Although a and b are very similar, one is capitalized and one isn’t. Because they aren’t exactly alike, Python returns False when we ask whether they are alike. Whitespace matters, too.
Consider the following code snippet:>>> greet1 = "Hello "
>>> greet2 = "Hello"
>>> greet1 == greet2 False greet1 has a space at the end of its string whereas greet2 does not. Python looks at whitespace when comparing strings, so the two aren’t considered equal