Skip to content

Commit 10cbe56

Browse files
Improve UX
1 parent 0d98b0c commit 10cbe56

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

exercises-sprint5/enums.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,14 @@ def find_possible_laptops(laptops: List[Laptop], person: Person) -> List[Laptop]
9191
print(f"Error: {age_str} is not a valid age. Please enter a number.")
9292

9393
# Convert OS string to enum with error handling
94-
try:
95-
os = OperatingSystem(os_str)
96-
except ValueError:
97-
print(f"Error: '{os_str}' is not a valid OS. Valid options are: Ubuntu, macOS, Arch Linux", file=sys.stderr)
98-
sys.exit(1)
94+
# Convert OS string to enum with error handling
95+
os = None
96+
while os is None:
97+
try:
98+
os = OperatingSystem(os_str)
99+
except ValueError:
100+
print(f"Error: '{os_str}' is not a valid OS. Valid options are: Ubuntu, macOS, Arch Linux", file=sys.stderr)
101+
os_str = input("Enter preferred OS: ")
99102

100103

101104
# Create Person object from validated input

0 commit comments

Comments
 (0)