def digital_root(n):
s=0
if n < 10:
return n
else:
while n>0:
s+=n%10
n=n//10
digital_root(s)
I am having trouble submitting this question.
I made sure to return the digit and i checked that the digit was correct by outputting it to the logs, but the tests keep failing and saying that I am returning None. I am not.
You need a return before the recursive call:
def digital_root(n):
s=0
if n < 10:
return n
else:
while n>0:
s+=n%10
n=n//10
return digital_root(s) # added 'return' here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With