Write a Python program to count Please include comments and
Write a Python program to count. Please include comments and screenshots, thank you!
1.)the frequency of words in a file (hint: use Counter module)
2.)the sentences
3) the words
Solution
file=open(\"C:\\\\file.txt\",\"r+\") wordcount={} for word in file.read().split(): if word not in wordcount: wordcount[word] = 1 else: wordcount[word] += 1 for k,v in wordcount.items(): print k, v