Question: #Write a function called word _ count. word _ count takes as #input a string called my _ string, and returns as output the #number

#Write a function called word_count. word_count takes as
#input a string called my_string, and returns as output the
#number of words in the string. For the purposes of this
#problem, you can assume that every space indicates a new
#word; so, the number of words should be one more than the
#number of spaces. You may also assume that any strings are
#not empty, so there should always be at least one word if
#my_string is a string.
#
#Note, though, that it could be the case that a non-string
#is accidentally passed in as the argument for my_string. If
#that happens, an error will arise. If such an error arises,
#you should instead return "Not a string". Otherwise,
#return an integer representing the number of words in the
#string.

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!