import datetime c=0 y=2015 d = datetime.date(y, 1, 1) d1 = datetime.timedelta(days=1) while d.year != y + 1: c += (d.month == (d.day // 10 + d.day % 10))*1 d = d + d1 print(c)