forked from BogdanOtava/CS50x
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmario.py
More file actions
28 lines (19 loc) · 657 Bytes
/
Copy pathmario.py
File metadata and controls
28 lines (19 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
https://cs50.harvard.edu/x/2023/psets/6/mario/less/
"""
def get_height():
"""Returns the height that was given by the user."""
while True:
try:
height = int(input("Height: "))
if height > 0 and height < 9:
return height
except ValueError as error:
print(error)
def print_pyramid(height):
"""Prints out the pyramid."""
for line in range(height):
print(" " * (height - line - 1), end="")
print("#" * (line + 1))
# Call the function that prints the pyramid which takes as argument the function that returns the height.
print_pyramid(get_height())