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)