def digit_sum(n): m = str(n) i=0 w =0 while i < len(m): k=m[i] w +=int(k) i+=1 if i == len(m): print w digit_sum(1234567) Please help ! I tried this code. But I am getting an error.
from the instructions:
For example: digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4
see the word
return in that line? It indicates you need to use the return keyword,
return w instead of printing it
The rest of the code is fine
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.