Creating a Number Pyramid
<p>I first off would like to say this may be classified as a duplicate post, based on my current research:</p>

<p><a href="http://stackoverflow.com/questions/38537364/how-to-do-print-formatting-in-python-with-chunks-of-strings?noredirect=1&amp;lq=1">How to do print formatting in Python with chunks of strings?</a>
and 
<a href="http://stackoverflow.com/questions/19129279/number-pyramid-nested-for-loop">Number Pyramid Nested for Loop</a>
and
<a href="http://stackoverflow.com/questions/13077491/pyramid-of-numbers-in-python">pyramid of numbers in python</a></p>

<p>[Edit: The reason I cannot use the conclusions to these previous questions very similar to mine is that I cannot use anything except what we have covered in my class so far. I am not allowed to use solutions such as: len, map, join, etc. I am limited to basic formats and string conversion.]</p>

<p>I'm in the process of working on an assignment for my Python class (using 3.0+) and I've reached a point where I'm stuck. This program is meant to allow the user to input a number from 1 to 15 as a line count and output a number pyramid based on their choice, such as the following example where the user would input 5:</p>

<pre><code>               1
             2 1 2
           3 2 1 2 3
         4 3 2 1 2 3 4
       5 4 3 2 1 2 3 4 5
</code></pre>

<p>So far I've gotten to the point where I can successfully print inputs 1 through 9, but have run into 2 issues.</p>

<ul>
<li>Inputs from 10 to 15 the numbers become misaligned (which users in the above posts seemed to have as well).</li>
<li>I can't seem to correctly format the printed numbers to have spaces in between them like my example above</li>
</ul>

<p>My current code for the program is:</p>

<pre><code>print("This program creates a number pyramid with 1 to 15 lines")

lines = eval(input("Enter an integer from 1 to 15: "))

if lines &lt; 16:
    for i in range(1, lines + 1):
        #Print leading space
        for j in range(lines -  i,  0,  -1):
        print(" ", end = '')
        #Print left decreasing numbers      
        for j in range(i, 0, -1):
            print(j, end = '')
        #Print right increasing numbers
        for j in range(2, i + 1):
            print(j, end = '')
        print("")

else:
    print("The number you have entered is greater than 15.")
</code></pre>

<p>And my current output is:</p>

<pre><code>Enter an integer from 1 to 15: 15
              1
             212
            32123
           4321234
          543212345
         65432123456
        7654321234567
       876543212345678
      98765432123456789
     109876543212345678910
    1110987654321234567891011
   12111098765432123456789101112
  131211109876543212345678910111213
 1413121110987654321234567891011121314
15141312111098765432123456789101112131415
</code></pre>

<p>I am asking you guys out of a desire to learn, not for anyone to code for me. I want to understand what I'm doing wrong so I can fix it. Thank you all in advance!</p>

<ol>
<li>You need to print one space more for the numbers from 10 to 15 because there is an extra character you have to take into consideration. If you change your max number to 100, you will need another space(total of 3), and so on. This means that instead if <code>print(" ")</code> you have to use <code>print(" " * len(str(j)))</code>, where <code>*</code> duplicates the space <code>len(str(j))</code> times and <code>len(str(j))</code> counts the number of digits from j. Also, if you want the pyramid properly aligned, you have to print another space, the one between numbers. </li>
<li>To add a space between numbers, you have to print the space<br>
<code>print(j, end=' ')</code></li>
</ol>

python python-3.x numbers alignment shapes