+ 1
Filing in python
How to write a program to count the frequency of the words in a file?
5 Answers
+ 3
Great man đ thanks for the missing part
Literally I forgot about that đ
+ 2
# open file in read mode
file = open("example.txt", "r")
# make count variable for word
# which has default value 0
count = 0
# read file line by line
for line in file:
# read each word of each line
for word in line:
if word == "example":
Count += 1
print ("frequency of word is: ", count)
# I think you got my point....
+ 2
Yeah i gotcha. I'd try
for word in line.split():
if word == 'example':
count += 1
+ 2
yup i got it đ¤đ¤ Thankyou Shahzaib Raza đ¸đ¸ and Slick đ
0
Have you given it a shot? Let's see the code and see what problems youre having