when I run the code gives back name 'make_pyramid' is not defined
:
from cs50 import get_int
while True:
print("Height: ", end="")
h = get_int("")
if h < 0 or h > 10:
print("height must be between 0 and 10")
else:
break
make_pyramid(h)
I know I can just rewrite this code above but if i did not want to do so, what else can i do?
def make_pyramid(h):
for i in range(0,h,1):
for j in range(0,h - 1 -i ,1):
print(" ", end="")
for k in range(0,(i * 2) + 1, 1):
print("#", end="")
print("")
return
In your code you didn't define make_pyramid
before you used it, it has to be like:
def myfunc():
...
myfunc()