Digit_sum


#1

can any one tell me where my code went wrong?


#2

def digit_sum (n):
s=0
lis= []
while n!=0:
digit = n%10
lis.append(digit)
n = n // 10 # removing the rightmost number
print lis
for i in lis:
s+=i
return s

this is the working code, look and if something is not understading to you just ask


#3

thanks i got this program.


#4

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