'How to properly break out of a recursion method?

I have been doing some Leetcode recently to prepare for interviews and I have recently come across a problem with my code. I was wondering what was wrong with this code and why my code will not return false when it is supposed to. Any help is appreciated.

def isHappy(n):
    num = [int(i) for i in str(n)]
    newSum = 0
    for i in num:
        newSum += i ** 2
    if newSum != 1:
        print('repeating')
        try:
            isHappy(newSum)
        except RecursionError:
            return False
    return True

print(isHappy(2))


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source