def sum_divisors(n):
sum = 0
# Return the sum of all divisors of n, not including n
return sum
print(sum_divisors(0))
# 0
print(sum_divisors(3)) # Should sum of 1
# 1
print(sum_divisors(36)) # Should sum of 1+2+3+4+6+9+12+18
# 55
print(sum_divisors(102)) # Should be sum of 2+3+6+17+34+51
# 114
I attempted to find the range of the numbers with this that I found on another question asked on here but I'm honestly just completely stumped with this question that I'm being asked even with the help that's alread given within the question.
for i in xrange(1,n/2+1):
if n%i == 0:
I'm not sure how to properly input it so it ended up looking like this
def sum_divisors(n):
for i in xrange(1,n/2+1):
if n%i == 0:
sum = 0
return sum
# Return the sum of all divisors of n, not including n
print(sum_divisors(0))
# 0
print(sum_divisors(3)) # Should sum of 1
# 1
print(sum_divisors(36)) # Should sum of 1+2+3+4+6+9+12+18
# 55
print(sum_divisors(102)) # Should be sum of 2+3+6+17+34+51
# 114