Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON programming, please! Write a program that counts how often each word occurs in the supplied text file mary.txt. Your program should output one line
PYTHON programming, please!
Write a program that counts how often each word occurs in the supplied text file mary.txt. Your program should output one line for each unique word that occurs in the text file in the format word: count, where word is a word from the file and count is the number of times that word occurs. Be sure to strip punctuation from words or your program will won't produce the correct output.
(Hint : The dictionary data structure should be used for this problem)
mary.txt is the following
Mary had a little lamb, whose fleece was white as snow. And everywhere that Mary went, the lamb was sure to go. It followed her to school one day which was against the rules. It made the children laugh and play, to see a lamb at school. And so the teacher turned it out, but still it lingered near, And waited patiently about, till Mary did appear. "Why does the lamb love Mary so?" the eager children cry. "Why, Mary loves the lamb, you know." the teacher did reply.
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