I need to make a pyramid in python using recursion.
Already made it, but I need help making it with recursion.
def pyramid(n):
for i in range(0, n):
for j in range(0, i+1):
print("* ",end="")
print("\r")
pyramid(5)
>Solution :
Recursion = the repeated application of a recursive procedure.
Code:
def pyramid(n):
if n==0:
return
else:
pyramid(n-1)
print("* "*n)
n = 10
pyramid(n)
This just repeats the function until n = 0.