I am writing a function to convert from decimal to binary system to practice recursion (not for school, uni, or the like!).
def toBin(n):
a = ''
if n <= 1:
return n
else:
if n > 1:
toBin(n//2)
b = (n % 2)
b = str(b)
a = a+b
print(a)
return a
print(toBin(99))
Why won't the function return '100011' but only its last digit ('1')?