Question: 8.5 LAB: Dictionary to count words - Python Write a full program that reads in a text file, and creates a dictionary to count how

8.5 LAB: Dictionary to count words - Python

Write a full program that reads in a text file, and creates a dictionary to count how often each word occurs in the file. You will need a nested for loop to find the count. Some code has been included for you. The ... means "to do" after the for, if, and else statements.

Ex: If the input is:

8.5 LAB: Dictionary to count words - Python Write a full program

Enter the name of a file: mary.txt and the mary.txt file contains: Mary had a little lamb Whose fleece was white as snow. And everywhere that Mary went, The lamb was sure to go! the sorted output is: And: 1 Mary: 2 The: 1 Whose: 1 a: 1 as: 1 everywhere: 1 fleece: 1 go!: 1 had: 1 lamb: 2 little: 1 snow. : 1 sure: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!