+ 1
Filing in python
How to write a program to count the frequency of the words in a file?
5 Antworten
+ 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