Answer :
Answer:
def words_in_both(a, b):
a1 = set(a.lower().split())
b1 = set(b.lower().split())
return a1.intersection(b1)
common_words = words_in_both("She is a jack of all trades", 'Jack was tallest of all')
print(common_words)
Explanation:
Output:
{'all', 'of', 'jack'}
The program returns the words which exists in both string parameters passed into the function. The program is written in python 3 thus :
def words_in_both(a, b):
#initialize a function which takes in 2 parameters
a1 = set(a.lower().split())
#split the stings based on white spaces and convert to lower case
b1 = set(b.lower().split())
return a1.intersection(b1)
#using the intersection function, take strings common to both variables
common_words = words_in_both("She is a jack of all trades", 'Jack was tallest of all')
print(common_words)
A sample run of the program is given thus :
Learn more : https://brainly.com/question/21740226
