Answer:
Hi there! There are a number of ways to achieve the word count result given an input text. The easiest method is explained below.
Explanation:
A simple Python script, word_count.py, can be used to calculate the word count program. The first argument is taken as the input text string (it needs to be enclosed in quotes (" ") in the command line). This input text is then split by spaces to capture the complete words list in an array. Finally, the length of the array equals the word count.
word_count.py
import sys;
text = sys.argv[1];
words = text.split(" ");
wc = len(words);
print(wc);