Created
May 18, 2022 02:48
-
-
Save dasunsucharith/b64928187dd006bd5235d68cc475955e to your computer and use it in GitHub Desktop.
CS50 2022 Psets 6 Mario-more Problem Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO | |
from cs50 import get_int | |
# get input from user until input is correct | |
while True: | |
try: | |
height = get_int("Height: ") | |
if (height >= 1) and (height <= 8): | |
break | |
except: | |
print("", end="") | |
for row in range(height): | |
for space in range(height - row - 1, 0, -1): | |
print(" ", end="") | |
# print the left hashes | |
for left_hash in range(row + 1): | |
print("#", end="") | |
# Print the middle seperation spaces | |
print(" ", end="") | |
# print the right hashes | |
for right_hash in range(row + 1): | |
print("#", end="") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment