Hi, all! I'm trying to solve https://exercism.org/tracks/python/exercises/perfect-numbers/ with this code:
`"""
A function to find if a number is perfect, abundant or deficient.
https://exercism.org/tracks/python/exercises/perfect-numbers
"""
def classify(number: int) -> str:
"""Find if a number is perfect, abundant or deficient based on its aliquot sum.
A perfect number equals the sum of its positive divisors, abundant number is less than
its aluquot sum, otherwise, it is a deficient number.
:param number: int a positive integer
:return: str the classification of the input integer
"""
if number <= 0:
raise ValueError("Classification is only possible for positive integers.")
divisors = []
for i in range(1, number):
if number % i == 0:
divisors.append(i)
if sum(divisors) == 1 or sum(divisors) > number:
return "deficient"
if sum(divisors) == number:
return "perfect"
else:
return "abundant"
`
The problem is that it fails couple of the tests and I am not sure why. I've applied screenshots to the assertion errors that are easy to see and that's why I can't understand why the answers are like that:
12 -> [1, 2, 3, 4, 6] -> the sum is 16 -> should be deficient
30 -> [1, 2, 3, 5, 6, 10, 15] -> the sum is 42 -> should be 'deficient'
4 -> [1, 2] -> the sum is 3 -> should be 'abundant'
32 -> [1, 2, 4, 8, 16] -> the sum is 31 -> should be 'abundant'
Can someone help me what am I missing here? The output of the tests is completely illogical to me.