From 144e844b26150bf1b8b7043cf643f0138b0f99f9 Mon Sep 17 00:00:00 2001 From: Ravitejavelamuri <39962669+Ravitejavelamuri@users.noreply.github.com> Date: Thu, 1 Oct 2020 00:46:47 +0530 Subject: [PATCH] Update Assignment 7.2.py --- week7/Assignment 7.2.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/week7/Assignment 7.2.py b/week7/Assignment 7.2.py index a1eadaf..78659a0 100644 --- a/week7/Assignment 7.2.py +++ b/week7/Assignment 7.2.py @@ -13,17 +13,17 @@ # Updated assignment asks users to not use sum() function or variable name in their solution # Use the file name mbox-short.txt as the file name -fname = raw_input("Enter file name: ") +fname = input("Enter file name: ") if len(fname) == 0: fname = 'mbox-short.txt' fh = open(fname) -count = 0 -tot = 0 +c = 0 +t = 0 ans = 0 for line in fh: if not line.startswith("X-DSPAM-Confidence:") : continue - count = count + 1 - num = float(line[21:]) - tot = num + tot -ans = tot / count -print "Average spam confidence:", ans + c = c + 1 + n = float(line[21:]) + t = n + t +ans = t / c +print("Average spam confidence:", ans)