-2
def divSum(number):
  divisors = [1]
  for i in range(2, number):
    if (number % i)==0:
      divisors.append(i)
  return sum(divisors)
l=[]
def isFriendly(x):
  if x==1:
    return False
  elif x in l:
    return True
  else:
    l.append(x)
    #x=divSum(x)
    isFriendly(divSum(x))

z = isFriendly(20)
print(z)

However, if I replace "return" with "print", it prints correctly. I tried a sample function (instead of calling isFriendly) to just accept a number and return True if the input number is 1, else False and it returned the correct output.

Any suggestions appreciated.

1 Answers1

0

You are not returning anything for the last else loop. That's why it is returning None. However, your list , l, does get populated. try printing l instead of z after calling the function.

MusHusKat
  • 32
  • 2