Question: Write a program which requests a sentence from the console and calls a function named count Words() which counts the number of words in
Write a program which requests a sentence from the console and calls a function named count Words() which counts the number of words in a sentence (using the English language). This function should accept a string as an input parameter and return the number of words as an integer. Remember that a string is an array of characters and has many built in functions. Note that a sentence must have one or more words. Sample Output Enter a sentence: Hello Number of words = 1 Enter a sentence: I am going to the store Number of words = 6 Activate Windows
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
mainpy 1 def countWords sentence Split the sentence into words using whitespace as the s... View full answer
Get step-by-step solutions from verified subject matter experts
