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

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!