python Sum of digits eg #4


SUBMITTED BY: Guest

DATE: Dec. 16, 2013, 8:44 a.m.

FORMAT: Python

SIZE: 166 Bytes

HITS: 855

  1. # find sum of digits
  2. n = input("enter an integer : ")
  3. print(str.join(" l", n))
  4. print(eval(str.join(" + ", n)))
  5. print(eval('+'.join(list(n))))

comments powered by Disqus