Created
July 23, 2016 21:29
-
-
Save manichabba/7da787b84f36c58a45d768d44ae679bf to your computer and use it in GitHub Desktop.
Python exercise 7.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spam = 0.0 | |
Count = 0 | |
fname = raw_input("Enter file name: ") | |
try: | |
fh = open(fname) | |
except: | |
print "File cannot be opened:",fname | |
exit () | |
for line in fh: | |
if not line.startswith("X-DSPAM-Confidence:") : continue | |
spam = spam + float(line[line.find(" ")+1:]) | |
Count = Count + 1 | |
print "Average spam confidence:",spam / float(Count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment