(Feb-10-2021, 03:45 PM)deanhystad Wrote: Without following the link my guess is you have a code branch inside your function that doesn't end in a return. Do you have any if statements?
No, rechecked it before. There is no if or any other conditional to prevent return at line #16. Even the line #13 prints the list 'new', i.e. one line before the return statement.
The code is stated below:
n = 4562; rev = 0 new= [] m = 0 def convert(n,m): print "round #:", m,"n :", n a = ((n+1) % 3)-1 if n: new.append(a); print 'new :', new convert((n+1)//3,m+1) else: print 'n==',n, 'new: ::: ', new return new print convert(n,m), "<<---- None returned ? " sum = 0 def value(l): sum = 0 for i in range(0, len(new),1): sum += new[i]*(3**i) print "sum :" , sum return sum print value(new), "<<---- Value is returned "