from datetime import date, timedelta d = date(2015, 1, 1) p = 0 while d.year == 2015: if d.month == (d.day//10 + d.day%10): p += 1 d += timedelta(days = 1) print(p)