Created
June 24, 2021 11:50
-
-
Save ozguripekci/4aaea23f0f3122c4636c44af28576306 to your computer and use it in GitHub Desktop.
PY4E 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
#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