what’s wrong in this code

```
def digit_sum(n):
a=0
while n:
b=n%10
a+=b
n=n/10
if n==0:
print a
break
```

i got output as 11.

Error:Your function fails on digit_sum(434). It returns None when it should return 11.

what’s wrong in this code

```
def digit_sum(n):
a=0
while n:
b=n%10
a+=b
n=n/10
if n==0:
print a
break
```

i got output as 11.

Error:Your function fails on digit_sum(434). It returns None when it should return 11.

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