title: Formatting Pascal's triangle
body: <p>I am currently working on a homework assignment to generate what is known as <a href="http://en.wikipedia.org/wiki/Pascals_triangle" rel="nofollow">Pascal's triangle</a> in Python.</p>
  
  <p>So far, this is what I have:</p>
  
  <pre><code>def mytri(myrange):
      trianglevar = [[1]]
      for i in range(1, myrange):
          tempvar = [1]
          for n in range(0, i-1):
              tempvar.append(trianglevar[i-1][n]+trianglevar[i-1][n+1])
          tempvar.append(1)
          trianglevar.append(tempvar)
      return trianglevar
  
  def mymenu():
      for i in mytri(int(raw_input("Please enter the height of the triangle: "))):
          print i
      print '\n'
      choicevar = raw_input("Would you like to create another triangle? (y/n): ")
      if choicevar == "y":
          mymenu()
      else:
          print "Goodbye."
  
  mymenu()
  </code></pre>
  
  <p>What the program does up to this point is perform the calculation for the triangle. It calculates the numbers in each row (starting with 1), and stops after reaching the number of rows specified by the user.</p>
  
  <p>However, I'm not sure how to format my triangle. It currently prints as:</p>
  
  <pre><code>[1]
  [1, 1]
  [1, 2, 1]
  [1, 3, 3, 1]
  [1, 4, 6, 4, 1]
  ...etc.
  </code></pre>
  
  <p>The output I want is:</p>
  
  <pre><code>        [1]
        [1, 1]
      [1, 2, 1]
    [1, 3, 3, 1]
  [1, 4, 6, 4, 1]
  ...etc.
  </code></pre>
  
  <p>(It's a bit off due to the brackets/commas, but I'm just trying to get the general format down right now.)</p>
  
  <p>Thank you for any help you can offer!</p>