To compare for equality, for case sensitive comparisons, Use ‘==‘‘an’ == ‘a’+’n’
For case insensitive comparisons, convert one to lower case before using ‘==‘a=‘Hello’
a.casefold() == ‘hello’
Obviously to check for inequality use !=You can also use >, <, <= and >= to test for relative ordering of strings - so called dictionary ordering.‘aardvark’ <= ‘ambleforth’
WarningDon’t ever use ‘is’ to compare for equality - while it will work for some small strings due to the way that Python currently internally manages memory it won’t work in the general case and using it can cause some subtle bugsNote : An Earlier version of this answer suggested using .lower() - it is better to use .casfold() as above as casefold deals more correctly with none ASCII character sets (i.e. those in use everywhere across the world except English speaking countries). You might think you will only ever run your code in the UK or USA, but you can’t control who else might use your code, and where else they might run it. Time to form good habits.