What is wrong with my second For Loop (spaces)? It seems like it only runs one time, according to the first line of the pyramid.
import cs50
while True: print("Type a number between 0 and 23: ", end="") n = cs50.get_int() if n > 0 or n < 23: break i=0 spaces = n - 1 for i in range(i,n,+1): for spaces in range(spaces,0,-1): print(" ", end="") spaces = spaces - 1 print("#" * (i+2), end="") print()
import cs50
while True:
print("Type a number between 0 and 23: ", end="")
n = cs50.get_int()
if n > 0 or n < 23:
break
i=0
spaces = n - 1
for i in range(i,n,+1):
for spaces in range(spaces,0,-1):
print(" ", end="")
spaces = spaces - 1
print("#" * (i+2), end="")
print()
Results Type a number between 0 and 23: 5 ##
Type a number between 0 and 23: 5
##
###
####
#####
######