From 8db5bb1b6212e99c4b9f12128d77980ff3c74396 Mon Sep 17 00:00:00 2001 From: IshaSinghgit <83011972+IshaSinghgit@users.noreply.github.com> Date: Sat, 22 Oct 2022 19:05:02 +0530 Subject: [PATCH] Added Code for frequency count in a text file --- Frequency.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Frequency.py diff --git a/Frequency.py b/Frequency.py new file mode 100644 index 0000000..14ae9c8 --- /dev/null +++ b/Frequency.py @@ -0,0 +1,6 @@ +from collections import Counter +def word_count(fname): + with open(fname) as f: + return Counter(f.read().split()) + +print("Number of words in the file :",word_count("Try.txt"))