Hi, I'm working on a project for my class in which recursion MUST be use to display a corresponding amount of lines to a user's input. So far I have this code.
I can't figure out why it only prints a single asterisk per line and doesn't add one subsequently.
Any help is appreciated. Thank you.
For anyone who viewed this, thank you. I was able to figure it out. If anything hopefully this can help someone in the future
n = int(input("How many line to display? ")) def show_ast(n): if(n>0): show_ast(n-1) num = n; st = "" while(num>0): st +='*' num -= num print(st) show_ast(n)




I can't figure out why it only prints a single asterisk per line and doesn't add one subsequently.
Any help is appreciated. Thank you.
For anyone who viewed this, thank you. I was able to figure it out. If anything hopefully this can help someone in the future


n = int(input("How many line to display? ")) def show_ast(n): if(n>0): show_ast(n-1) num = n st = "" while(num>0): st += '*'*num num -= num print(st) show_ast(n)I just multiplied the number of asterisks in the while loop by the user input.