import re, sys # assume weather data from weather.csv sys.stdin.readline() count = 0 bad = 0 total_snow = 0 for line in sys.stdin: #print(line) match = re.match('([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),([^,]*),', line) # could just use L = line.split(',') if match: #print(match.groups()) count += 1 snow = match.groups()[2] if snow != 'T': total_snow += float(snow) #print(snow) #break else: #print('No match') bad += 1 #break; print('Bad lines: ' + str(bad)) print('Good lines: ' + str(count)) print('Average snow/year: ' + str(total_snow / (count/365.25)))