0
from cs50 import get_int

print("height: ",end="")
height = get_int()
while True:
    # prompt user for height
    if height >= 0 or height <= 23:
        break
    else:
        print("retry!!!")

for i in range(height):
    print("" * (height - i - 1), end="")
    print("#" * (i + 2))
0

The reason is that you are not printing the spaces. Look carefully at these two statements:

 print("" * (height - i - 1), end="")

and

 print(" " * (height - i - 1), end="")

Can you see the difference?

2
  • yes I see the difference. The second statement inside the print function has a double quotations which are one space apart. Nov 2 '18 at 7:29
  • Thanks it works very nicely. Nov 2 '18 at 7:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .