To write a python program for getting the word count from a text.
PC Anaconda - Python 3.7
Start the program.
Give the input string.
Print the original string.
using len(test_string.split()) get the result.
Print the word count.
End the program.
#python program for word count
#Developed by : RIYA P L
#Reference no : 23005672
def wordcount(filename):
count=0
with open(filename,"r") as f:
for data in f:
words=data.split()
for word in words:
count+=1
print("Total number of words:",count)
filename=input("Enter Filename:")
wordcount(filename)
![word1](https://private-user-images.githubusercontent.com/138971519/292658571-bf8ac0e1-9e91-4cbc-b12e-9061f9c97d73.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMTc5NjQsIm5iZiI6MTcyNTMxNzY2NCwicGF0aCI6Ii8xMzg5NzE1MTkvMjkyNjU4NTcxLWJmOGFjMGUxLTllOTEtNGNiYy1iMTJlLTkwNjFmOWM5N2Q3My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMlQyMjU0MjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04YWE2N2IyMDUwYTRjZjVmNjdkOGY1NTgzYjM4OTlmNGViNzM5MTQwNzVkNDNjZTAyYTYyNjNjMDA2MDM5ZWFiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.ZPbfXMSTAJTRFrPecS5qKEMZwsuho85OWi5P2Q-4Z2c)
![word2](https://private-user-images.githubusercontent.com/138971519/292658577-d4c05b9b-175f-4d9d-949c-3b2ddadac881.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUzMTc5NjQsIm5iZiI6MTcyNTMxNzY2NCwicGF0aCI6Ii8xMzg5NzE1MTkvMjkyNjU4NTc3LWQ0YzA1YjliLTE3NWYtNGQ5ZC05NDljLTNiMmRkYWRhYzg4MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAyJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMlQyMjU0MjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lYmEzZTQ2ZTc0ZmU3ZTY2OTEzOTE0OGNmNWIzNWM3NWViMGFhZWIzMGQ4NGI1NjEyYTNhMjg4MTcwMDcxNWNhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Xo__EcQ0xUKrzVmZMMxfM2q1TMko-9FOzVWDCzMtloA)
Thus the program is written to find the word count from a text.