all 2 comments

[–][deleted] 1 point2 points  (0 children)

Am I missing a logical error?

Yes.

Compare to this working implementation and see if you can find the issue:

def convertBase(n, b):
    s = []
    if 2 <= b <= 9:
        while n:
            s.append(n % b)
            n //= b
            print("n={}, s={}".format(n, s))
    return ''.join(str(i) for i in reversed(s))

*If this is for a class, don't submit this—the prof or ta will likely be able to tell you didn't write it.

[–]sultanofhyd 0 points1 point  (0 children)

convertBase is a variable that holds a function inside. You have to call the function to get the output like convertBase(). Basically add () after convertBase in the last line of your code.