linecount = 0
for line in f:
    l = line.split()
try:
    num = float(l[1])
except ValueError:
    continue
if l[0] == 'X-DSPAM-Confidence:':
    s += num
linecount += 1
print(s / linecount)
I am learning Python, need some pushing in the right direction