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
10 changes: 5 additions & 5 deletions week7/Assignment 7.2.py~
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ You can download the sample data at http://www.pythonlearn.com/code/mbox-short.t
#Average spam confidence: 0.750718518519

# Use the file name mbox-short.txt as the file name
fname = raw_input("Enter file name: ")
fname = input("Enter file name: ")
fh = open(fname)
l = []
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
ll = line.split()
for x in fh:
if not x.startswith("X-DSPAM-Confidence:") : continue
ll = x.split()
for i in ll:
try:
u = float(i)
l.append(u)
except:
pass
print "Average spam confidence:",sum(l)/len(l)
print("Average spam confidence:",sum(l)/len(l))