4. count_these_terms Given a list of words of any length, and a list of search terms, build a dictionary mapping from each search term to the number of times it appears in the first list. Make sure to include every search term in the output dictionary! Sample calls should look like:

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 19VE
icon
Related questions
Question
### QUESTION FOUR ###
def count_these_terms (words, search_terms ):
pass
Transcribed Image Text:### QUESTION FOUR ### def count_these_terms (words, search_terms ): pass
4. count_these_terms
Given a list of words of any length, and a list of search terms, build a dictionary mapping from each search term to the
number of times it appears in the first list. Make sure to include every search term in the output dictionary!
Sample calls should look like:
>>> count_these_terms("fred fred fred fred ted bimmy".split(), ["fred"])
{'fred': 4}
>> count_these_terms("fred fred fred fred ted bimmy". split(), ["fred", "sally"])
{'fred': 4, 'sally': 0}
>> count_these_terms("sally fred sally fred ted bimmy".split(), ["fred", "sally"])
{'fred': 2, 'sally': 2}
Transcribed Image Text:4. count_these_terms Given a list of words of any length, and a list of search terms, build a dictionary mapping from each search term to the number of times it appears in the first list. Make sure to include every search term in the output dictionary! Sample calls should look like: >>> count_these_terms("fred fred fred fred ted bimmy".split(), ["fred"]) {'fred': 4} >> count_these_terms("fred fred fred fred ted bimmy". split(), ["fred", "sally"]) {'fred': 4, 'sally': 0} >> count_these_terms("sally fred sally fred ted bimmy".split(), ["fred", "sally"]) {'fred': 2, 'sally': 2}
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Dictionary
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning