Question: 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
Get step-by-step solutions from verified subject matter experts
