To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Decleare number of words is 0
open it with txt file
Give range for i
Then nxt split the words
count the number of words
Giving print statement for getting output
num_words =0
with open('text.txt','r') as file1:
for i in file1:
word =i.split()
num_words += len(word)
print("Number of words={}".format(num_words))
Thus the program is written to find the word count from a text.