Assume the availability of a function named printStars that can be passed a parameter containing a non-negative integer value. The function prints out the given number of asterisks.
Write a function named printTriangle that receives a parameter that holds a non-negative integer value and prints a triangle of asterisks as follows: first a line of n asterisks, followed by a line of n-1 askterisks, and then a line of n-2 asterisks, and so on.
For example, if the function received 5, it would print
*****
****
***
**
*
The function must not use a loop of any kind (for, while, do-while) to accomplish its job. The function should invoke printStars to accom;lish the task of printing a single line.
I have the base case worked out I believe. Here is my code:
def printTriangle(n):
if n == 1:
printStars(n)
I need some help figuring out the recursive step. I am thinking it uses n-1 as a parameter, but I am not sure how to call the printTriangle function properly. Thanks in advance.