input: Write a python function to print a pyramid pattern.
  assert pyramid(3) == """  * 
   * * 
  * * * 
  """
  assert pyramid(4) == """   * 
    * * 
   * * * 
  * * * * 
  """
  assert pyramid(5) == """    * 
     * * 
    * * * 
   * * * * 
  * * * * * 
  """
output: def pyramid(n):
      result = []
      for i in range(n):
          spaces = ' ' * (n - i - 1)
          stars = '* ' * (i + 1)
          result.append(spaces + stars.strip())
      return '\n'.join(result) + '\n'