title: How to reverse a shape in python?
body: <p>I am hunter and I had a question out of interest for an upcoming exam. Basically I was wondering if there is a way to make and shape (triangle in this case) invert. </p>
  
  <p>Below is my code. But I also have another code. Just wondering if there is an easier way than scraping and rewriting again.</p>
  
  <pre><code>def a(b):
      num = 1
      count= 0
  
      for i in range(0, b):
          row = ''
  
          for k in range(0, b-i):
              row = row + '      '
          count=count+2
  
          for j in range(1, count):
              if (num &lt;10):
                  row = row+'     '+str(num)
              if (num&gt;9 and num&lt;99):
                  row = row+'    '+str(num)
              if (num==99):
                  row = row+' '
              if (num&gt;=99 and num&lt;=1000):
                  row = row+'   '+str(num)
              if (num&gt;=1001 and num&lt;=10000000):
                  row = row+'  '+str(num)
              num = num +1
          print '\r'
          print(row)
  
  b= input(str("number of rows:  "))
  
  a(b)
  
  
  def a(number):
      ctr = 1
      while(ctr &lt;= number):
          row_spaces= ' ' * (number - ctr)
          row = (2*ctr-1) * '$'
          print(row_spaces+row)
          ctr = ctr +1
  
  number= input(str("what is the amount of rows?  "))
  a(number)
  </code></pre>