To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Open flie in read mode.
Read the text using read funcion.
Split the text using space separator.
The length of the split list should be equal to the number of words in the text file.
Now give print().
End the program.
##DEVELOPED BY:K.DeviJhansi
##REFERNCE NUMBER:21005096
num_words = 0
with open('text1.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.