Write a program word_count.py
that has the user enter a sentence or a series of words. The program should then call a function count(string)
that goes through the string, counts how many words are in that string, and returns that value to the main program.
There are a number of different strategies for counting words in a string. Use these test cases to see how well your function works.
STRING EXPECTED WORD COUNT
"Hi" 1
"Hello there" 2
"Hi Mom" 2
"Hi, Mom" 2
" Here I am " 3
" How about this " 3
" How about this? " 3