In this we are going to see a basic program to find the frequency of words in a file in Python Programming Language.
def word_frequency():
f = open("file.txt", "r")
words = f.read().split()
f.close()
word_freq = {}
for word in words:
if word in word_freq:
word_freq[word] += 1
else:
word_freq[word] = 1
print(word_freq)
word_frequency()
# Coded By Dhiraj Shelke
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP