4 Digit_sum


This is a bit confusing and the hint doesn’t really help me much…

def digit_sum(n):
n = str(n)
total = 0
for i in n:
i = int(i)
total += i
return total


It returns “4” instead of “11”


Check where your return is. If inside the loop, take back some indent so it is not.


It was inside the loop, it works perfectly now. Thanks! :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.