Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

project-8b Write a function named words_in_both that takes two strings as parameters and returns a set of the words contained in both strings. You can

project-8b

Write a function named words_in_both that takes two strings as parameters and returns a set of the words contained in both strings. You can assume all characters are letters or spaces. Capitalization shouldn't matter: "to", "To", "tO", and "TO" should all count as the same word. The words in the set should be all lower-case. For example, if one string contains "To", and the other string contains "TO", then the set should contain "to".

You can use Python's split() funciton, which breaks up a string into a list of strings. For example:

sentence = 'Not the comfy chair!' print(sentence.split()) ['Not', 'the', 'comfy', 'chair!'] 

Here's one simple example of how words_in_both() might be used:

common_words = words_in_both('She's a jack of all trades', 'Jack was tallest of all') 

The file must be named: words_in_both.py

code in python

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

WHAT IS AUTOMATION TESTING?

Answered: 1 week ago

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago