The word in is a boolean operator that takes a value and a sequences and returns True if the first appears in the second.
For example, the following function prints all the letters from word1 that also appear in word2:
With well-chosen variable names, Python sometimes reads like English. You could read this loop, “for (each) letter in (the first) word, if (the) letter (appears) in (the second) word, print (the) letter.”
Here’s what you get if you compare apples and oranges:
For strings, in indicates if a value appears as a substring:
The in operator also works on lists.
It will also work with other kinds of sequences.