Given a natural number N. Calculate the sum of its numbers. Where I nakosyachil? PS do not need to offer me a solution in cycles. I am interested in the logic of working out my code. Why my code does not work?
a = input() a = str(a) result = 0 count = 0 def summa_cifr(a, count, result): c = '' c = c + a[count] c = int(c) result = result + c if count < len(a): return summa_cifr(a,count+1, result) else: return result summa_cifr(a, count, result) print(result)
count = len(a) -1? PS Using lines is useless here - MBo pm