from datetime import date,timedelta d = date(2015, 1, 1) end = date(2016, 1, 1) ans = 0 while d < end: month = d.month day = d.day if month == sum(divmod(day, 10)): ans += 1 d += timedelta(days=1) print(ans)