import datetime today = datetime.date(2015, 1, 1) nextday = datetime.timedelta(days =1) ans = 0 while today.year == 2015 : x = today.month y = today.day if x == y // 10 + y % 10 : ans += 1 today += nextday print(ans)