Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions week7/Assignment 7.2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)