0

Write a function called printStars. The function receives a parameter containing an integer value...

Write a function called printStars. The function receives a parameter containing an integer value. If the parameter is positive, the function prints (to standard output) the given number of asterisks. Otherwise the function does nothing. The function does not return a value. Thus, if printStars(8) is called, ******** (8 asterisks) will be printed. The function must not use a loop of any kind (for, while, do-while) to accomplish its job. Instead, it should examine its parameter, returning if the parameters value is not positive. If the parameter is positive, it: prints a single asterisk (and no other characters) then crecursively calls itself to print the remaining asterisks ------------------------------- This is what i have so far: def main(): printStars(8) def printStars(times): if times > 0:   print('*') printStars(times - 1) What am i doing wrong?

11th Feb 2020, 11:53 PM
Philip
Philip - avatar
2 Respostas
+ 2
def printStars(num): if num > 0: print("*", end="") printStars(num-1) Thx u all for helping me out, appreciate
12th Feb 2020, 6:10 AM
Philip
Philip - avatar