Question
Write a PYTHON module with a function to determine the 5 most common words in a string using a dictionary. Your function should take a
Write a PYTHON module with a function to determine the 5 most common words in a string using a dictionary. Your function should take a string as a parameter and return a list of the 5 most common words in that string. Within the main body of your code, define a tuple of at least 4 text passages, each of which should have 6 or more sentences. You may use any sample texts youd like quotes from your favorite books/movies/TV shows, excerpts from famous speeches, etc. just look them up on Google and copy and paste.
Your program should print out a menu to the user with the titles of the passages in your tuple (consider using another function to do this) and allow them to select which excerpt to count the common words in.
Then, call your function with the chosen text passed in as an argument, and print out the returned value of the 5 most common words in the text. Finally, allow the user to choose whether or not to pick another text to analyze. If they choose yes, print out the menu again and repeat. If not, end the program.
Please fill with comment and make it easy to follow.
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