title: How to print a triangle in python?
body: <p>I want to make a function to print triangle like the following picture. User can insert the row number of the triangle. The total lenght of first row is must an odd.</p>
  
  <p>I try to use below code : </p>
  
  <pre><code>def triangle(n): 
      k = 2*n - 2
      for i in range(0, n): 
          for j in range(0, k): 
              print(end=" ") 
          k = k - 1
          for j in range(0, i+1): 
              print("* ", end="") 
          print("\r") 
  n = 5
  triangle(n) 
  </code></pre>
  
  <p>Here is the expected output image :</p>
  
  <p><a href="https://i.stack.imgur.com/mxng3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mxng3.png" alt="expected output"></a></p>
  
  <p>and here is my actual output image : </p>
  
  <p><a href="https://i.stack.imgur.com/KkCWJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KkCWJ.png" alt="real output"></a></p>
  
  <p>but I can't remove the star middle star. And it's not Upside - Down Triangle</p>