def happydaychecker(x,y)->bool: return x-(y//10+y%10) == 0 dayss = [] for i in range(1,13): for j in range(1,32): dayss.append((i,j)) NSDD = [(2,29),(2,30),(2,31),(4,31),(6,31),(9,31),(11,31)] days = list(filter(lambda x: x not in NSDD,dayss)) counter = 0 for n in range(365): if happydaychecker(*days[n]) == True: counter +=1 print(counter)