fork download
  1. def digit_sum(n):
  2. total = 0
  3. while True:
  4. a = n % 10
  5. n = n // 10
  6. total = total + a
  7. if n < 1 :
  8. break
  9. return total
  10.  
  11. inputDigit = int(input())
  12. print digit_sum(inputDigit)
Success #stdin #stdout 0.01s 7696KB
stdin
12584521
stdout
28