I'm trying to extract the values inside a file so I can make an average.
fname = input("Enter file name: ")
fh = open("mbox-short.txt")
count = 0
total = 0
for line in fh:
    if not line.startswith("X-DSPAM-Confidence:"):
        continue
    a = line.find(":")
    line = line.strip()
    b = float((line.find[a + 1]))
    count = count + 1
    total = b + total
    print(total/count)
I can't use the function sum.
I try to use slice after the : and the output is wrong.
 
     
    