Here's yet another way using regular math, no loops, only recursion. (Trivial case 0 returns nothing).
def toBin(num): if num == 0: return "" return toBin(num//2) + str(num%2)print ([(toBin(i)) for i in range(10)])['', '1', '10', '11', '100', '101', '110', '111', '1000', '1001']