Created
October 8, 2019 16:20
-
-
Save bschne/e4eae873c8ade271603bdb0413f73ffc to your computer and use it in GitHub Desktop.
HS2019-Inf1-Lec4 Exercise 1
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
| #!/usr/bin/python3 | |
| def sum_of_digits(number): | |
| digit_sum = 0 | |
| for digit in str(number): | |
| digit_sum += int(digit) | |
| return digit_sum | |
| print("{} --> {}".format(1234, sum_of_digits(1234))) | |
| print("{} --> {}".format(100001, sum_of_digits(100001))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment