Adeola Adeoti

designs

Hire Me

CS50 Mario Python (More) Solution

from cs50 import get_int


# Request input and validate.
def main():
# Get and validate user input
while True:
print("Please input a number between 0-8. ", end="")
height = get_int("Height: ")
width = height
if height > 0 and height <= 8:
break

for i in range(1, height + 1):
num_hashes = i
num_spaces = width - num_hashes

print(" " * num_spaces, end="")
print("#" * num_hashes, end="")

# Print space
print(" ", end="")

print("#" * num_hashes)


if __name__ == "__main__":
main()