Question: Python Part 1: Unique Words Write a program that opens a user specified text file and then displays a list of all the unique words

Python

Part 1: Unique Words Write a program that opens a user specified text file and then displays a list of all the unique words found in the file. At the end include a count of how many unique words were found. Remove punctuation. Use the attached ShortText.txt file to debug your program, then use GettysburgAddress.txt for the final test (there are 138 unique words in the file). Hint: Create a dictionary using the words in the file as keys. Before adding a new key, use 'in' to determine if it is already in the dictionary.

Part 2: Modify the program to count and print the frequency of each word. Also print which word appears most often.Hint: Use the value of each dictionary item to count the number of times each word appears.

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!