Word Counter

Create a program that analyzes a text file and counts how many time various words are used within it.
User flow
1. The program asks a user what file to open.
2. The program then asks the user to enter a comma-separated list of words to analyze within the file.
3. The program then outputs the frequency of each word within the file.

Sample session
User responses are bold.
What file would you like to open? universal_declaration_of_human_rights_in_nigerian_pidgin_english.txt
What words would you like to search for? wey, dem, unifasiti, ting

... analyzing ... hold on ...

Frequency of word usage within universal_declaration_of_human_rights_in_nigerian_pidgin_english.txt:
    wey               / 19 occurrences
    dem             / 17 occurrences
    unifasiti       / 22 occurrences
    ting             / 63 occurrences

▪ Include a sample text file along with your code when submitting your assignment. Package both files into a zip file.
▪ If the user includes spaces in their list of words (as I have done in the example session above), they should be stripped out and ignored.
▪ capitalization should be ignored.
▪ there is no limit to how many words the user can enter.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#def main():
filename = input("What file would you like to open?: ")
# shakespeare.txt...

By purchasing this solution you'll be able to access the following files:
shakespeare.txt and

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats