Created
September 25, 2013 14:05
-
-
Save ProProgrammer/6700135 to your computer and use it in GitHub Desktop.
This file contains 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 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