Question: Write a module, most_common.py, with a function to determine the 5 most common words in a string using a dictionary . Your function should take

Write a module, most_common.py, 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 dictionary of at least 3 text passages, each of which should have 6 or more sentences. You may use any sample texts youd like.

Your program should print out a menu to the user with the actual titles of the passages in your dictionary (consider using another function to do this) and allow them to select which excerpt to count the common words in. Once they select the title, call your function with the text associated with that title 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.

Add comment and no import of any kind. Please keep it easy for a beginner to understand.

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!