I'm not sure what a certain code line does
<p>I was trying to have a program using Python to create a "pyramid" based on a number, n, out of o's and came up with this: ( I would print nn, that would be the lines.)</p>

<pre><code>import time

n = 0
while True:
    n += 2 #just another way to show n=n+2
    nn = n, "o" #nn would be an amount of o's, based on what #n was
    time.sleep(1)
    print (nn, str.center(40, " "))
</code></pre>

<p>Not sure how to make nn the o's and not sure what line 6 does either. Does anyone know the answer to either question? ( I'm not in a class just programming for fun.)</p>

<p>You can also use the <a href="https://docs.python.org/3/library/string.html#format-string-syntax" rel="nofollow">built-in formatting options</a> offered by python. Take a look at this:</p>

<pre><code>def pyramid_builder(height, symbol='o', padding=' '):
    for n in range(0, height, 2):  # wonkiness-correction by @mhawke
        print('{0:{1}^{2}}'.format(symbol*n, padding, height * 2))

pyramid_builder(20, 'o')
</code></pre>

<p>The <code>^</code> symbol says that you want your print <strong>centered</strong>. Before it (<code>{1}</code>) comes the padding symbol and after it (<code>{2}</code>) the total width.</p>

<p>This is fully customisable and fun to play with.</p>

python