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)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With