Trójkąt gwiazdki w pythonie [duplikat]

To pytanie ma już odpowiedź tutaj:

Jak odtworzyć trójkąt piramidy? 3 odpowiedzi

Muszę napisać funkcję rekurencyjną asterisk_triangle, która przyjmuje liczbę całkowitą, a następnie zwraca trójkąt z gwiazdką składający się z tylu wierszy.

Na przykład jest to 4-liniowy trójkąt gwiazdki.

*
**
***
****

Wymyśliłem tę funkcję:

def asterisk_triangle(n):
    """
    takes an integer n and then returns an
    asterisk triangle consisting of (n) many lines
    """
    x = 1
    while (x <= n):
        print("*" * x)
        x = x + 1
    return

A także musiałem stworzyć odwrócony trójkąt gwiazdkowy, manipulując pierwszą funkcją.

Wymyśliłem tę funkcję i wynik:

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 < n):
          print("*" * (n-x))
     x = x + 1
     return


****
***
**
*

Teraz muszę manipulować tymi funkcjami, aby utworzyć trójkąt z gwiazdką do tyłu.

   *
  **
 ***
****

I odwrócony trójkąt z gwiazdką.

****
 ***
  **
   *

Jakie funkcje powinienem wdrożyć?

Próbowałem użyć polecenia reverse string [:: - 1] po funkcji i nie działało.

questionAnswers(1)

yourAnswerToTheQuestion