Can somebody point out why am I getting infinite loop in this? I mean it shows error for maximum recursion depth reached? For value of '1' it shows correct output.
def beautiful(n):
new=str(n+1)
new.rstrip('0')
return int(new)
def check(n):
if n==1:
temp.extend(list(range(1,10)))
return
else:
temp.append(n)
return check(beautiful(n))
n=int(input())
temp=[]
check(n)
print(len(set(temp)))