0
from cs50 import get_int
import sys

height = get_int("Height: ")
if height > 8 or height < 1:
    print("invalid input")
    exit(1)

else:
    for i in range(0, height+1):
        for j in range(0, (height - i)):
            sys.stdout.write(" ")
        for h in range(0, i):
            sys.stdout.write("#")
        print("")
    exit(0)

enter image description here

1
  • 1
    this loop for h in range(0, i): doesn't execute on the first iteration (when i is 0) – DinoCoderSaurus Jun 2 '20 at 13:15

You must log in to answer this question.

Browse other questions tagged .