Project: Words in both
Write a function called words_in_both that takes two strings and returns a set
of the words that appear in both. You can assume every character is a letter or
a space. Capitalization does not matter, so "to" and "To" are the same word. The
words in the result set should be lower-case. For example, if one string has
"on" and the other has "ON", the set should contain "on".
Python's split() method helps here:
sentence = 'Not the comfy chair!'
print(sentence.split()) # ['Not', 'the', 'comfy', 'chair!']
Here is how the function could be used:
common_words = words_in_both("She's a jack of all trades", 'Jack was tallest of all')
Save the file as words_in_both.py.
Show a solution
Try the project on your own first. This is one working solution, followed by its tests. Press Run to run the tests. Read them to see what thorough testing looks like, then change the solution and run again to watch a test fail.
Projects run on your own computer, so you tell us when you are done.