Write the function getCommonLetters(word1, word2)
that takes in two words as arguments and returns a new string that contains letters found in both string. Ignore r
You can use set intersection
>>> ''.join(set('apple').intersection(set('google')))
'el'
The function can be defined as
def getCommonLetters(a, b):
return ''.join(sorted(set(a).intersection(set(b))))
Example
>>> def getCommonLetters(a, b):
... return ''.join(sorted(set(a).intersection(set(b))))
...
>>> getCommonLetters('google','apple')
'el'