Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function called in python howManyWordsAndSentences that takes in a string. Your function should return a dictionary where the keys are the order position
Write a function called in python howManyWordsAndSentences that takes in a string.
Your function should return a dictionary where the keys are the order position of each
SENTENCE (you may assume sentences will end with periods, exclamation points, or question
marks). The data for each key should be a tuple containing the number of words in the sentence
and a string containing the sentence itself (you should remove the extra spaces before or after
each sentence).
Your function should print out how many sentences there are in the input string.
Ex: For the input string
Our class string is I Love Chocolate Milk. This may seem silly. But I really do love chocolate
milk!
Your dictionary would have 3 entries
The first key would be 1, and the data would be 8 (number of words) and the string Our class
string is I Love Chocolate Milk. The second key would be 2, and that data would be 4 (number
of words) and the string This may seem silly. The third key would be 3, and the data would be
7 (number of words) and the string But I really do love chocolate milk!
Important to not use any outside packages
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