Question: Part A . Write a function wordDictFromFile ( ) that processes a file and aggregates word counts into a dictionary. The function takes a filename
Part A Write a function wordDictFromFile that processes a file and aggregates word counts into a dictionary. The function takes a filename parameter:
filename, an input file containing multiple lines in the format
word:count word:count
where word is a string and count is an integer. The function returns a dictionary of key: value pairs, where each key is a word from the file and its corresponding value is the total count for that word.
For example, if an existing input file, input.txt contains:
it: is: fun: what:
python: is: fun:
printwordDictFromFileinputtxt will display
it:is: 'fun': 'what': 'python':
Part B Given the existing file input.txt and a target count Write code that utilizes the
wordDictFromFile function to produce and print on the screen the list of distinct words with a total word count no more than target. The output for the given example would be itis 'what 'python'
Edit Format Table
pt Paragraph
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
