From e91ddaa040904538b2a8a3fbe312ae092f72555e Mon Sep 17 00:00:00 2001 From: K V Ragul <cb.en.u4cse16237@cb.students.amrita.edu> Date: Sun, 6 Jan 2019 15:51:00 +0530 Subject: [PATCH] lab 3 --- CSE16237_Ex03_q2.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 CSE16237_Ex03_q2.py diff --git a/CSE16237_Ex03_q2.py b/CSE16237_Ex03_q2.py new file mode 100644 index 0000000..e2e30f3 --- /dev/null +++ b/CSE16237_Ex03_q2.py @@ -0,0 +1,14 @@ +path='/home/student4/sun.txt' +sun_file=open(path,'r') +categories = {} +line = sun_file.readline().strip().split("/sun_") +category = line[0][3:] +while len(category)>0: + if category in categories.keys(): + categories[category]+=1 + else: + categories[category]=1 + line = sun_file.readline().strip().split("/sun_") + category = line[0][3:] + +print(categories) -- GitLab