In [42]:
def answer(x):
# your code here
#I will turn x into a string
#then I will loop through each item
#then I will sum each item, forcing back to int
#I will then check if the len(str(x)) >1
#if so, repeat.
if len(str(x)) == 1:
print x
return x
else:
result = 0
for item in str(x):
result = result + int(item)
return answer(result)
In [43]:
answer1 = answer(52345265)
In [44]:
print answer1
In [ ]: