from datetime import datetime, timedelta startDate = datetime(2015, 1, 1) happyDay = 0 for i in range(365): addedDate = startDate + timedelta(days=+i) day = addedDate.day month = addedDate.month if len(str(day))==2: digits = [int(digit) for digit in str(day)] if month == (digits[0] + digits[1]): happyDay+=1 else: if month == day: happyDay+=1 i+=1 print(happyDay)