Read this for more on strings.
The word in
is a boolean operator that takes two strings and returns True
if the first appears as a substring in the second:
>>> 'a' in 'banana' True >>> 'seed' in 'banana' False
word1
that also appear in word2
:
def in_both(word1, word2): for letter in word1: if letter in word2: print(letter)
>>> in_both('apples', 'oranges') a e s