Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need a Python function frequency_match(text, chars) that receives a string text and a dictionary chars that has characters as keys and numbers as values. The
Need a Python functionfrequency_match(text, chars)that receives a stringtextand a dictionarycharsthat has characters as keys and numbers as values. The function must return a list with all the characters that occur in the text as many times as their associated value in thechardictionary.
Not all the chars in the text will be present in the dictionary, but you may assume that all the chars in the dictionary are in the text. You are allowed to change the values in the dictionary.
For example:
print(frequency_match("The green forest", {'e':3, 'h':2, ' ':2, 'f':1})) [' ', 'f'] print(frequency_match("121314532330001", {'1':3, '2':2, '3':3, '4':1})) ['2', '4']
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started