Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

fix: handle user-defined number of solutions (#18) #29

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions search.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,21 @@

print(stdout.decode('utf-8'))
print(stderr.decode('utf-8'))

pyoverflow3.submit_error(str(stderr),2)
try:
# Ask the user how many solutions they would like to see
num_solutions = int(input("How many solutions would you like to see? "))
if num_solutions < 1 or num_solutions > 3:
# for out of range request, using default of 2 with a message
print("Please enter a number between 1 and 3. Using default value of 2.")
num_solutions = 2

except ValueError:
# catch block for non-integer input
print("Invalid input. Using default")
num_solutions = 2

pyoverflow3.submit_error(str(stderr), num_solutions)


except Exception as e:
print("QuickOverflow Error: " + e)
print("QuickOverflow Error: " + e)