Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save som983/cdf83adcc2ed1f90fe4da665e4030b8e to your computer and use it in GitHub Desktop.

Select an option

Save som983/cdf83adcc2ed1f90fe4da665e4030b8e to your computer and use it in GitHub Desktop.
flname = input("Enter the file name: ")
fhandle = open(flname)
count = 0
total = 0
for i in fhandle:
if not i.startswith("X-DSPAM-Confidence:"):
continue
else:
t = i.find("0")
num = float(i[t+1:].rstrip())
count = count + 1
total = total + num
avg=total/count
print("Average spam confidence: ",avg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment