Question: Write a function named count_words that takes a character array (x) and returns the number of words in it (count) as shown in the example.

 Write a function named count_words that takes a character array (x)

Write a function named count_words that takes a character array (x) and returns the number of words in it (count) as shown in the example. Assume that the chatacter array is only composed of spaces and letters i.e, there are no special characters such as comma, column, semicolon, etc. in the character array. Be careful, there may be more than one space between words!!! The code has already been provided to define a function named count_ words that accepts input variable x. In your code, make sure to use adequate loop(s) and conditional(s). def count_words (x) : \#n\# Write the code for your function below this wine. return count Example Cases: xoutput=Helloworldofwonder:=4 x= 'This is another example for the function output =7 xoutput==0

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!