To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Assign a variable for value zero
open then required file by using the function 'with'
Then use the for loop for assignment the i value in the file
using split function to split the words
Finding the length of the words by using len() function
Calling the function and printing the number of words.
## DEVELOPED BY: R.Vijay
## REFERENCE NUMBER: 21500269
num_words =0
file1 = open("text.txt", "r")
print(file1.read())
with open('text.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 file.