Skip to content

Commit 94f584e

Browse files
committed
Fix ValueError in Question-number user input: stackexchange
1 parent c3d2af3 commit 94f584e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/arguments/utility.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ def get_ans(self, questions_list):
164164
console.rule("[bold blue]", style="bold red", align="right")
165165
# Asks the user for next question number. Makes it the active question and the loop restarts
166166
while True:
167-
posx = int(input("Enter the question number you want to view (Press 0 to quit): ")) - 1
167+
try:
168+
posx = int(input("Enter the question number you want to view (Press 0 to quit): ")) - 1
169+
except ValueError:
170+
SearchError("You didn't enter a question number", "Enter a question number from the relevant questions list")
168171
if (posx == -1):
169172
return
170173
elif (0<=posx<len(questions_data)):

0 commit comments

Comments
 (0)