1def perfect_number(n):
2 sum = 0
3 for x in range(1, n):
4 if n % x == 0:
5 sum += x
6 return sum == n
7print(perfect_number(6))
1n = 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!")