Skip to content

Conversation

@Krishna-Ravi
Copy link

This is another easier way to get the required output.

# Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
c = 0
lst = []
total = 0.0
for line in fh:
    if not line.startswith("X-DSPAM-Confidence:") : continue
    f = (line.split())
    c+=1
    lst.append(f[1])
    
for i in lst:
    total +=float(i)

print("Average spam confidence:",total/len(lst))

This code is done by me and found this easier and thought this might help others too.
:)

This is another easier way to get the required output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant