Answer:
The solution code is written in Python 3.
- def printStars(count):
- for i in range(0, count):
- print("*", end="")
-
- starCount = 8
- print("*", end="")
- printStars(starCount-1)
Explanation:
Firstly, create a function printStars() that take one integer value as argument. (Line 1 -3)
- To print the asterisks based on the input integer, count, we can use the for-loop and Python in-built method range() (Line 2-3)
- The range() method will accept two arguments, start index and stop index, which will control the number of iterations the for-loop will go through. If the count = 5, the for-loop will traverse through the range of number from 0, 1, 2, 3, 4 (A total of 5 rounds of iterations).
Once the function printStars() is ready, create a variable starCount and initialize it with 8 (Line 5).
Print the first asterisk (Line 6) and then followed with calling the function printStars() to print the remaining asterisk (Line 7). The argument that passed to the printStarts() function is starCount-1 as the first asterisk has been printed in Line (6).