weekday = [5] month = (31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30) def leap_day(year): if not (year % 400): return 1 if (year % 100) and (not (year % 4)): return 1 return 0 for y in range(1900, 2001): for m in month: weekday.append((weekday[-1] + m) % 7) if 28 == m: weekday[-1] = (weekday[-1] + leap_day(y)) % 7 print(weekday[13:].count(0))