You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I suppose the answer will be 38444 instead of 38549.
import re
fh = open("mbox.txt")
count = 0
total = 0
for line in fh:
line = line.rstrip()
lst = re.findall('[A-Za-z]+ [A-Za-z]+: ([0-9]+)', line)
if len(lst) > 0:
for x in lst:
total += int(x)
count += 1
print(total // count)
I used this code to fetch the result.
For mbox-short.txt the result is correct as mentioned i.e. 39756
while for mbox.txt its 38444 instead of 38549.
I would be happy if you could correct me if I'm wrong. :) @csev@ck39
Exercise 2 at the bottom of chapter 11 Regex (https://www.py4e.com/html3/11-regex)
The solution to the average for 'mbox-txt':
I think the answer should be 38549.7949721 ?
The text was updated successfully, but these errors were encountered: