Files
plants_scad/utils.py
T

29 lines
792 B
Python

#!/bin/python3
from __future__ import annotations
def ask_int(prompt: str) -> int:
"""Prompt user for a positive integer."""
while True:
try:
value = int(input(prompt).strip())
if value <= 0:
print("Please enter a positive integer.")
continue
return value
except ValueError:
print("Please enter a valid integer.")
def ask_float(prompt: str) -> float:
"""Prompt user for a positive float."""
while True:
try:
value = float(input(prompt).strip())
if value <= 0:
print("Please enter a positive number.")
continue
return value
except ValueError:
print("Please enter a valid number.")