How to make triangle x in python from source code below
<p>Hello I want to ask everybody...
Like this...
I want to make a triangle X or *, like below:</p>

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

<p>My Algorithm is like this:</p>

<pre><code>for y:=1 to i do
    for x:=1 to j do
       for j-x to 1 do write(' ');
       for i to 2*(x-1)+1 do write('*');
</code></pre>

<p>Can anybody tell me how is the source code for python like pascal in above?
Thanks for your answer</p>

<p>You can simply do this like that:</p>

<pre><code>def triangle(lines):
    for i in range(lines):
        print(' '*(lines-i) + '*'*(i*2+1))

triangle(5)
</code></pre>

<p>Output as expected</p>

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

python algorithm pascal