Question: THIS IS A PYTHON PROBLEM ON CODESTEPBYSTEP: http://www.codestepbystep.com/problem/view/python/strings/word_count Write a function named word_count that accepts a string as its parameter and returns the number of
THIS IS A PYTHON PROBLEM ON CODESTEPBYSTEP: http://www.codestepbystep.com/problem/view/python/strings/word_count
Write a function named word_count that accepts a string as its parameter and returns the number of words in the string. A word is a sequence of one or more non-space characters (any character other than ' '). For example, the call of word_count("hello, how are you?") should return 4.
Constraints: Do not use any data structures such as arrays to help you solve this problem. Do not use the string function split on this problem. But you can declare as many simple variables like int, str, etc. as you like. Declaring String variables is also fine.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
