[Solved] RECURSIVE function that will sum digits of input


Convert back and forth between strings and ints, make use of sum().

>>> def foo(n):
    n = str(n)
    if len(n) == 1:
        return int(n)
    return foo(sum(int(c) for c in n))

>>> foo(1969)
7
>>> 

def foo(n):
    n = str(n)
    if len(n) == 1:
        return int(n)
    return foo(sum(int(c) for c in n))

2

solved RECURSIVE function that will sum digits of input