Created
May 10, 2015 23:19
-
-
Save bowbahdoe/3f9599481bc9d9fcba94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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