import re, sys header = sys.stdin.readline() days = 0 mean_total = 0 for line in sys.stdin: fields = re.match('([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*)\n', line) if fields: groups = fields.groups() data = {'date':groups[0], 'prcp':groups[1], 'snow':groups[2], 'snwd':groups[3], 'tmax':groups[4], 'tmin':groups[5], 'mean':groups[6], 'extra':groups[7]} #print(data) #break days += 1 mean_total += float(data['mean']) # but note that fields = line.split(',') is simpler print('Total # of years, days = ' + str(days/365.0) + ', ' + str(days)) print('Average mean temp = ' + str(mean_total / days))