Check out this simpler version.
x = eval(input("Enter a number: ")) s = 0 for i in range(1, x): if x % i == 0: s += i print(s)