Hi All,

I get the error message:

-Your function crashed on 1000 as input because your function throws a "string index out of range" error.

-Your function fails on digit_sum(434). It returns 1 when it should return 11

Can someone show me where my code is going wrong?

Thanks!

```
n=input("enter a number")
n_str=str(n)
def digit_sum(n):
total=0
for x in range(0,len(str(n))):
num_str=n_str[x]
#print(num_str)
total=total+int(num_str)
print("Your total is: %s"%(total))
return total
print(digit_sum(n))
```