python3 12 digits script each digit equal three time beore him?
Question: Write a program that displays **12 digits** ,

each digit is equal to three times the digit before him.

I tried to code like this

    
    
    a , b , c = 1 , 1 , 1
    
    print(c)
    
    while c < 12 :       # for looping
    
        c = c + 1        # c for counting
    
        b = a+b
    
        y = 3*b
    
        print(c,y)
    

can any one help me to correct the result


Answer: You can use [power
operator](https://docs.python.org/3/reference/expressions.html#the-power-
operator) for that:

    
    
    from itertools import islice
    
    def numbers(x, base=3):
        n = 0
        while True:
            yield x * base ** n
            n += 1
    
    for n in islice(numbers(1), 12):
        print(n)
    

Or if you really like your way of doing that, here's a fixed version of your
code:

    
    
    b, c = 1, 0
    while c < 12:
        print(c, b)
        b *= 3
        c += 1
    

