This commit is contained in:
Joeri Exelmans 2024-11-21 14:20:54 +01:00
parent 87fdb8c190
commit a0eb56421f

View file

@ -53,10 +53,10 @@ class InteractiveDecisionMaker(DecisionMaker):
sys.stdout.write(f"{self.msg} ") sys.stdout.write(f"{self.msg} ")
try: try:
raw = input() raw = input()
choice = int(ord(raw)-97) # may raise ValueError choice = ord(raw)-97 # may raise ValueError
if choice >= 0 and choice < len(arr): if choice >= 0 and choice < len(arr):
return arr[choice] return arr[choice]
except ValueError: except (ValueError, TypeError):
pass pass
print("Invalid option") print("Invalid option")
return __choose() return __choose()