Skip to content

Instantly share code, notes, and snippets.

@bowbahdoe
Created May 10, 2015 23:19
Show Gist options
  • Select an option

  • Save bowbahdoe/3f9599481bc9d9fcba94 to your computer and use it in GitHub Desktop.

Select an option

Save bowbahdoe/3f9599481bc9d9fcba94 to your computer and use it in GitHub Desktop.
def sumDigits(number):
stringRepresentation = str(number)
total = 0
if(number < 10):
return number
for digit in stringRepresentation:
total += int(digit)
return sumDigits(total)
def main():
while(True):
try:
num = (raw_input("Enter Number: "))
num = int(num)
print str(sumDigits(num))
except Exception as a:
print a
print("That is not a number")
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment