From d9fe11fe72395d5bd3d7982c8467a4fb6a4eae14 Mon Sep 17 00:00:00 2001 From: aslesha <cb.en.u4cse16259@cb.students.amrita.edu> Date: Wed, 19 Dec 2018 12:06:04 +0530 Subject: [PATCH] lab3 q1 --- cse16259_e3_1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 cse16259_e3_1.py diff --git a/cse16259_e3_1.py b/cse16259_e3_1.py new file mode 100644 index 0000000..85d80c2 --- /dev/null +++ b/cse16259_e3_1.py @@ -0,0 +1,18 @@ +fname = input("Enter the name of the file:") +infile=open(fname,'a') +infile.write("append the sentences:") +infile = open(fname, 'r') +wordcount={} +lines = 0 +for word in infile.read().split(): + if word not in wordcount: + wordcount[word] = 1 + else: + wordcount[word] += 1 +print (word,wordcount) +infile.close(); + + + + + -- GitLab