To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
create a text file using jupyter
now open the text file sample.txt
to open use with open() function
now to count split the text by giving split()
give for loop to count
by now it gets added and gives output
#Program to find the word count
# developed by: FRANKLIN RAJ G
# REGISTER NO:23001518
num=0
with open("sample.txt","r") as f1:
for i in f1:
word=i.split()
num+=len(word)
print("the number of words are in the file is",num)
Thus the program is written to find the word count from a text.