I should be extracting the float 0.875, but I get 0.0
I don’t know why. I’ll post my code below and a link to the challenge. I can’t figure out why I’m not getting the correct answer. Can you help please?
import re
handle = open('mbox-short.txt')
numlst = list()
for line in handle:
line = line.rstrip()
stuff = re.findall('^X-DSPAM-Confidence: ([0-9]+)', line)
if len(stuff) != 1: continue
num = float(stuff[0])
numlst.append(num)
print('Maximum: ', max(numlst))
This checks for any string beginning with ‘X-DSPAM-Confidence:’ that is followed by a colon and any amoung of numbers 0-9 followed by or including a decimal.