diff --git a/search.py b/search.py index d04a509..da2abdc 100755 --- a/search.py +++ b/search.py @@ -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) \ No newline at end of file + print("QuickOverflow Error: " + e) \ No newline at end of file