I wrote a code that outputs "Yes" when the input number is a perfect number, and outputs "No" when the number isn't. But when I input 6, it outputs "No". I have specified it to print "Yes" with if-else statements when the sum of divisors equal to the original input. Why is the output wrong?
n=int(input())
myList=[]
for i in range(1,n):
if n%i==0:
myList.append(n)
sum=0
for i in range(0,len(myList)):
sum=sum+myList[i]
if sum==n:
print("Yes")
else:
print("No")