Skip to content

Instantly share code, notes, and snippets.

@bschne
Created October 8, 2019 16:20
Show Gist options
  • Select an option

  • Save bschne/e4eae873c8ade271603bdb0413f73ffc to your computer and use it in GitHub Desktop.

Select an option

Save bschne/e4eae873c8ade271603bdb0413f73ffc to your computer and use it in GitHub Desktop.
HS2019-Inf1-Lec4 Exercise 1
#!/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