Answer:
#function to count number of words in a string
def num_words(str1):
# using split() to count words in string
res = len(str1.split())
return res
test_string = input("Enter string:")
# printing original string
print ("The original string is : " + test_string)
# printing result
print("Number of word in entered string:")
print (num_words(test_string))
Explanation: