count the frequency of words in a file

Solutions on MaxInterview for count the frequency of words in a file by the best coders in the world

showing results for - "count the frequency of words in a file"
Marco
09 Nov 2018
1from collections import Counter
2def word_count(fname):
3        with open(fname) as f:
4                return Counter(f.read().split())
5
6print("Number of words in the file :",word_count("test.txt"))