Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ProProgrammer/6700135 to your computer and use it in GitHub Desktop.
Save ProProgrammer/6700135 to your computer and use it in GitHub Desktop.
"""def digit_sum(n):
nlist = []
count = 0
for n in str(n):
nlist.append(n)
for i in nlist:
count += int(i)
return count"""
def right_most_digit(n):
return n % 10
def digit_sum(n):
count = 0
for i in range(len(str(n))):
for i in enumerate(str(n)):
print i
count += right_most_digit(n)
n //= 10
return count
print digit_sum(4110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment