import datetime y = 2015 f = lambda x: sum(map(int, list("{:0>2}".format(x)))) if __name__ == '__main__': cnt = 0 d = datetime.date(y, 1, 1) td = datetime.timedelta(days=1) while d.year == y: if f(d.month) == f(d.day): cnt += 1 d += td print(cnt)