Python Code Example: Perfect number

A number is called perfect if the number is equal to the sum of its divisors (the number itself is not considered a divisor in this case).

sum = 0
number = int(input("Enter a number to check for perfect: "))

for i in range(1, number):
    if number % i == 0:
        sum = sum + i

if sum == number:
    print(str(number) + " is a perfect number")
    print(str(number) + " is not a perfect number")
Enter a number to check for perfect: 28
28 is a perfect number