in, not in

Strings can also be used with conditional statements. In the last topic we saw that we could create a boolean expression with boolean operators like >, ==, >=, and, not. Strings can also use those operators with the addition of two more. not as well as not in.

The >, < operators will add the ascii values for all letters in a string and will compare the resulting integers. So “cat” will have a higher integer value that “bat”.

String Comparison

You’ll notice that we can search for letters or sequence of letters within a word (also known as a String) using the in and not in keywords. These both return a boolean value that we can then use in a conditional statement: