I was solving a problem on Codewars involving recursion and I've never really done it before but kinda understand the concept. Im not really good at math stuff so it probably explains why I cant wrap my head around this. Essentially I think I kinda did the loop right I just dont know how to print the final value. Anyway heres my code:
def digital_root(n):
newn = 0
list = [int(x) for x in str(n)]
if len(list) >= 2:
for i in range(len(list)):
newn += list[i]
digital_root(newn)
return n
print(digital_root(1234)
output:
1234