CodeWars problem:
Create a function named divisors that takes an integer and returns an array with all of the integer's divisors(except for 1 and the number itself). If the number is prime return the string '(integer) is prime'
My code below runs perfectly when I tested it in Spyder3 for Python.
def divisors(integer):
arr = []
for x in range(2,integer - 1): #if integer is 12
if integer % x == 0:
arr.append(x)
if len(arr) == 0:
print(integer, 'is prime')
else:
print(arr)
However, when I submit it to CodeWars, it returns the following error:
divisors(15)
should return [3, 5]; my function does this. The CodeWars window log shows that the answer is right, but proceeds to say None should equal [3, 5]
.
I checked to see if it was returning a something other than a list, but that checks out. Can anybody spot the problem?