Happy Number Challenge

I am having an issue with the Happy Number challenge. My code works when I use 7 as a custom test case, but fails the test when I go to submit my code. Any insight would be appreciated. Here's my code:

    def isHappy(self, n, num_set= set()):
        """
        :type n: int
        :rtype: bool
        """
        if n==1:
            return True
        
        else:
            happy_str=0
            for num in str(n):
                happy_str += (int(num) ** 2)

        if happy_str in num_set:
            return False

        num_set.add(happy_str)
        return self.isHappy(happy_str, num_set)```
Comments (0)