Creating pattern using simple loops?
<p>I am trying to create this pattern in python:</p>

<pre><code>    *
   * *
  * * *
   * *
    * 
</code></pre>

<p>This is my program so far that I've come up with:</p>

<pre><code>ster = "*"
space = " "
lines = 0
n = 3
x = 1
while lines &lt;= 5:
    print space*n, ster*x
    n-= 1
    x+= 1
    lines += 1
</code></pre>

<p>What am I doing wrong?</p>

<p>Notice you have</p>

<ul>
<li>3 spaces for 1 star</li>
<li>2 spaces for 2 stars</li>
<li>1 space for 3 stars.</li>
</ul>

<p>For the upright triangle part of your diamond (including the large part). Then you have</p>

<ul>
<li>2 spaces for 2 stars</li>
<li>3 spaces for 1 star</li>
</ul>

<p>Without throwing out the answer, try analysing a certain pattern in what i've just pointed out. It can be achieved with 2 loops ( for or while, depending on your preference).</p>

python python-2.7 loops