perfect number in python

n = int(input("Enter any number: "))sum1 = 0for i in range(1, n):if(n % i == 0):sum1 = sum1 + iif (sum1 == n):print("The number is a Perfect number!")else:print("The number is not a Perfect number!")

Here is what the above code is Doing:
1. We are taking input from the user.
2. We are initializing a variable sum1 to 0.
3. We are using a for loop to iterate from 1 to n.
4. We are checking if n is divisible by i.
5. If n is divisible by i, we are adding i to sum1.
6. If sum1 is equal to n, we are printing that the number is a Perfect number.
7. If sum1 is not equal to n, we are printing that the number is not a Perfect number.