4. digit_sum


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
4.digit_sum

<In what way does your code behave incorrectly? Include ALL error messages.>
It doesn’t. When I try the code IDLE it works flawlessly but when I try it in CodeAcademy it throws up the following error “Your function fails on digit_sum(434). It returns None when it should return 11.”

<What do you expect to happen instead?>
The code to. I have tried digit_sum(434) on IDLE and it gives 11. There are no formatting errors in my code.
This is annoying as I can’t access the next challange due to this.

```python

def digit_sum(n):
result = 0
for i in str(n):
result += int(i)
print result

<do not remove the three backticks above>

#2

Hi @websurfer79019,

This statement displays a value but it does not return a value …

  print result

You need to have the function return the value.


#3