Nested Loop in Python Not Working
<p>I would like to have this output:</p>

<pre><code>* * * 
2 2 2 
4 4 4  
6 6 6 
8 8 8
</code></pre>

<p>I cannot get it and I've tried many ways, but my code doesn't seem to work. Here is my current code:</p>

<pre><code>for row in range(3):
    print ("*", end = " ")
    print ()
    for col in range(2,9,2):
        print (row, end = " ")
        print ()
print()
</code></pre>

<p>What do I do?</p>

<p>For a start, you only have one row that contains <code>* * *</code> which can be printed at the very top, outside of any loops:</p>

<p><code>print('* * *')</code></p>

<p>Next, you would need to start your loop from values <code>2</code> (inclusive) and <code>9</code> (exclusive) in steps of <code>2</code>:</p>

<p><code>for col in range(2,9,2):</code></p>

<p>You don't need to use any <code>end</code> keyword here, so just printing the row multiple times is sufficient:</p>

<p><code>print('{0} {0} {0}'.format(i))</code></p>

<p>So the final block of code looks like:</p>

<pre><code>print('* * *')
for row in range(2,9,2):
    print('{0} {0} {0}'.format(row))
</code></pre>

<p>You don't need to add another <code>print()</code>, <code>print</code> already ends with a newline anyway.</p>

python