You missed the trailing “:”: while divisor < n:
.
There are also various problems with the indentation.
This may fix your code:
def sum_divisors(n):
sum = 0
divisor = 1
while divisor < n:
if n % divisor == 0:
sum = sum + divisor
divisor += 1
# Return the sum of all divisors of n, not including n
return sum
solved Python – SyntaxError: invalid syntax [closed]