Question: Write a Python program to do the following: 2. 1. Ask the user to enter several sentences, one at a time (in a loop).


Write a Python program to do the following: 2. 1. Ask the user to enter several sentences, one at a time (in a loop). To end the sentence entry, the user enters a blank (empty) sentence. Each sentence should be put in a list (SentenceList). Extract each word from each sentence and put it in a new list (WordList). This will require a loop to go through each sentence in the SentenceList. It is up to you how you want to get the words from each sentence. 3. After you get the list of all the words (WordList), calculate the number of times each word appears in the WordList. In order to do this, process the data (using a loop) to use a dictionary (WordDictionary) with the word as the key, and the count as the value. The words are not case sensitive. For example, "House" and "house" are the same words. Assume that the only punctuation used is a period. You must be able to remove the period while processing. In other words, "last" and "last." are the same since you need to remove the period. 4. Display the dictionary (Word Dictionary). When displaying the results, iterate through the dictionary so you can control the way the information is displayed. DO NOT simply print the whole dictionary at once. Example interaction: Program prompts the user for sentences, terminated but a blank/empty sentence: User enters: The house of thunder. User enters: The top of the list. User enters: Program displays: the: 3 house: 1 of: 2 thunder: 1 top: 1 list: 1 Very useful hint: This appears as a rather complex program in its entirety. If you try each part separately, you will gain the knowledge needed to build the full solution successfully. Submit the .py file, with header comments and any other comments you feel are necessary, to the folder for this assignment.
Step by Step Solution
There are 3 Steps involved in it
SentenceList while True sentence inputEnter a sentence or leave it blank to finish strip if not ... View full answer
Get step-by-step solutions from verified subject matter experts
