python3 12 digits script each digit equal three time beore him?
<p>Write a program that displays <strong>12 digits</strong>,</p>

<p>each digit is equal to three times the digit before him.</p>

<p>I tried to code like this </p>

<pre><code>a , b , c = 1 , 1 , 1

print(c)

while c &lt; 12 :       # for looping

    c = c + 1        # c for counting

    b = a+b

    y = 3*b

    print(c,y)
</code></pre>

<p>can any one help me to correct the result </p>

<p>You can use <a href="https://docs.python.org/3/reference/expressions.html#the-power-operator" rel="nofollow">power operator</a> for that:</p>

<pre><code>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)
</code></pre>

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

<pre><code>b, c = 1, 0
while c &lt; 12:
    print(c, b)
    b *= 3
    c += 1
</code></pre>

python python-3.x