To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Declare number of words as zero.
Open it with txt file.
Give range for i.
Then split the words.
Count the number of words.
End the Program
# Program to find Word count
# Developed by: Shalini.K
# Register no: 22008827
num_words =0
with open('file1.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.