-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (20 loc) · 661 Bytes
/
main.py
File metadata and controls
29 lines (20 loc) · 661 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
29
width_string: str = ""
def exit_with_message(message: str) -> None:
print(message)
raise SystemExit
def ask_length_of(length: str) -> int:
print(f"--- What is the {length} of the rectangle? ---")
try:
return int(input(f"{length.capitalize()}: ").replace(" ", ""))
except ValueError:
exit_with_message("Please enter a whole number without any decimals....")
except KeyboardInterrupt:
exit_with_message("\nYou exited the program!")
width: int = ask_length_of("width")
height: int = ask_length_of("height")
if height > 0:
for _ in range(width):
width_string = f"{width_string}."
if width > 0:
for _ in range(height):
print(width_string)