Question 3.
For this question you need to work with text. Write a function that takes in a two text files: one is a book, another file has names in it. You need to determine the 3 most popular
names in the book (from the given name list). To do this, implement two helper methods, name_count and make_tuple, that will assist you in finding the answer.
def name_count (file, name):
Function returns the number of names in
file that match the given name.
>>> name_count("little_women.txt", "Jo")
1543
>>> name_count("little_women.txt", "Meg")
685
>>> name_count("little_women.txt", "Troll")
0
# YOUR CODE HERE #
def make_tuple (name, freq):
Function returns a tuple of two inputs.
>>> make_tuple (5, 3)
(5, 3)
>>> make_tuple (2, 2)
(2, 2)
>>> make_tuple ('red', 5)
('red', 5)
#YOUR CODE HERE
def three most common names (text, text_names):
Function that takes in text (a book) and
text names (characters from the book).
You must implement this function to find
the three most common names in the book.
>>> three most common names ("little_women.txt", "names.txt")
['Jo', 'Meg', 'Amy']
# YOUR CODE HERE #