To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
create a new text file and add comment
create a python file and add program
Run the program
Get the output
Take the output as screenshot
End of the program.
fname=input("Enter file name:")
num_words=0
with open(fname,'r')as f:
for line in f:
word=line.split()
num_words+= len(words)
print("Number of words:",num_words)
Thus the program is written to find the word count from a text.