这是对codewars.com一个挑战,但我想不通,为什么这个while循环不起作用我不知道为什么这个while循环没有停止迭代
def digital_root(n):
# Creating variable combine to have the sum
combine = 0
# as long as n is more than two numbers.
while n > 10:
# converting n to string to iterate
for i in str(n):
# getting the sum each element in n
combine += int(i)
# reset n to be equal to the combined result
n = combine
return combine
也,任何解决方案,可以理解,这里是链接到挑战 https://www.codewars.com/kata/sum-of-digits-slash-digital-root
请在这里告诉我们一些背景。什么是n?你想用这个功能实现什么? –
n是一个数字,这里是我想要实现的链接https://www.codewars.com/kata/sum-of-digits-slash-digital-root –