Get a valid integer input between 0 and 2.
(prompt: str)
| 45 | |
| 46 | |
| 47 | def get_valid_input(prompt: str) -> int: |
| 48 | """Get a valid integer input between 0 and 2.""" |
| 49 | while True: |
| 50 | try: |
| 51 | value = int(input(prompt)) |
| 52 | if 0 <= value < 3: |
| 53 | return value |
| 54 | print("Invalid input: Enter a number between 0 and 2.") |
| 55 | except ValueError: |
| 56 | print("Invalid input: Please enter an integer.") |
| 57 | |
| 58 | |
| 59 | def main() -> None: |