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