import datetime oneday = datetime.timedelta(days=1) baseDate = datetime.date(2015, 1, 1) endDate = datetime.date(2015, 12, 31) cnt = 0 def check_happy(m: int, d: int, d2: int): global cnt if m == d + d2: cnt += 1 while not baseDate == endDate: m = baseDate.month d = baseDate.day one: int = 0 two: int = 0 if d > 10: strDay = str(d) one = int(strDay[0]) two = int(strDay[1]) else: one = 0 two = d check_happy(m, one, two) baseDate += oneday print(cnt)