title: Asterisk triangle in python
body: <p>I have to write a recursive function asterisk_triangle which takes an integer and then returns an asterisk triangle consisting of that many lines.</p>
  
  <p>For e.g this is a 4 line asterisk triangle.</p>
  
  <pre><code>*
  **
  ***
  ****
  </code></pre>
  
  <p>I came up with this function:</p>
  
  <pre><code>def asterisk_triangle(n):
      """
      takes an integer n and then returns an
      asterisk triangle consisting of (n) many lines
      """
      x = 1
      while (x &lt;= n):
          print("*" * x)
          x = x + 1
      return
  </code></pre>
  
  <p>And also I had to create an upside down asterisk triangle by manipulating the first function.</p>
  
  <p>I came up with this function and result:</p>
  
  <pre><code>def upside_down_asterisk_triangle(n):
       """
       takes an integer n and then returns a backwards
       asterisk triangle consisting of (n) many lines
       """
       x = 0
       while (x &lt; n):
            print("*" * (n-x))
       x = x + 1
       return
  
  
  ****
  ***
  **
  *
  </code></pre>
  
  <p>Now I have to manipulate these functions to create a backwards asterisk triangle.</p>
  
  <pre><code>   *
    **
   ***
  ****
  </code></pre>
  
  <p>And a backward upside down asterisk triangle.</p>
  
  <pre><code>****
   ***
    **
     *
  </code></pre>
  
  <p>What functions should I implement?</p>
  
  <p>I have tried using the reverse string command [::-1] after the function and it didn't work.</p>