def digit_sum(n): \'\'\'(int)->number Returns the sum of all the digits in the given integer, n\'\'\' if n<10: return n return n%10 + digit
def droot(a): while a>=10: b =int(a/10) #other digit(s) c =a-(b*10) #the rightmost digit a =b+c #add together return a
I have not seen this solution anywhere, so I thought it would be nice to share, i discovered it myself! Just 1 looping structure.