Your function fails on digit_sum(434). It returns 12 when it should return 11.
I have done it in normal way with Str() and it works, but i checked the hint and i want to try it with modulo and floor division, but seems that there is a problem (434 returns 12 instead of 11) but i don't know where,I think is something about the modulo and floor division operations. Can pls someone help?
here is the code:
def digit_sum(n): numero=0 for num in str(n): numero += n%10 n // 10 return numero