Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ozguripekci/4aaea23f0f3122c4636c44af28576306 to your computer and use it in GitHub Desktop.
Save ozguripekci/4aaea23f0f3122c4636c44af28576306 to your computer and use it in GitHub Desktop.
PY4E 7.2
#Take input from user
fname = input("Please inser file name:")
#try and except
try:
fhand = open(fname)
except:
print("File can not be found", fname)
quit()
#count and total
count= 0
total = 0
for line in fhand:
line = line.rstrip()
if not line.startswith("X-DSPAM-Confidence:"):
continue
else:
line = line[20:]
uline = line.upper()
fline = float(uline)
count = count+1
total = total + fline
avr = total / count
print("Average spam confidence:" ,avr )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment