-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
30 lines (26 loc) · 864 Bytes
/
utils.py
File metadata and controls
30 lines (26 loc) · 864 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
30
def pause():
input("\nPress Enter to continue...")
def get_menu_choice(min_val, max_val):
while True:
choice = input(f"Enter your choice ({min_val}-{max_val}): ")
if choice.isdigit() and min_val <= int(choice) <= max_val:
return int(choice)
print("Invalid choice. Please try again.")
def get_positive_number(prompt):
while True:
try:
value = float(input(prompt))
if value > 0:
return value
print("Value must be positive.")
except ValueError:
print("Invalid number.")
def get_non_negative_int(prompt):
while True:
try:
value = int(input(prompt))
if value >= 0:
return value
print("Cannot be negative.")
except ValueError:
print("Invalid integer.")