To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Assign a variable fpr value zero
Open the file required using the 'with' function
Use the for loop to assign the i values i the file
Use split function to split the words
Finding the length of the words by using len() function
Call the function and print the number of words
with open ("text.txt", 'r')as fp:
count = 0
for data in fp:
l=data.split ()
for i in l:
count += 1
print ("No of words in the file", count)
Thus the program is written to find the word count from a text.