import calendar def days_2015(m): month = calendar.monthcalendar(2015, m) month_set = [] for i in month: month_set.extend(i) month_set = list(set(month_set)) return month_set full_days_lists = [] for i in range(1, 13): full = days_2015(i) full_days_lists.append(full) month_end = [] for i in range(len(full_days_lists)): month_end.append(full_days_lists[i][-1]) count = 0 for i in range(len(month_end)): if i == 0: pass for j in range(month_end[i]): if i < 10 and i == j: count += 1 elif j >= 10: days = ((j // 10) + (j % 10)) if i == days: count += 1 print(count)