From b7f3993dd291209f56ed165441f1d1ea6113d04b Mon Sep 17 00:00:00 2001 From: baphim <269010393+baphim@users.noreply.github.com> Date: Sun, 13 Sep 2026 09:33:20 -0400 Subject: [PATCH] fix(problem-04.py): completed problem --- lab-02/problem-04.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lab-02/problem-04.py b/lab-02/problem-04.py index 69a8624..deac068 100644 --- a/lab-02/problem-04.py +++ b/lab-02/problem-04.py @@ -2,4 +2,18 @@ # not numerical. # Define the function to check if user input is a number -def numb_check(n): +def numb_check(x, y): + # Try of both numbers that were entered are numbers + try: + x = float(x) + y = float(y) + # Handle the expected ValueError if one of the variables is not a number + except ValueError: + # Raise the TypeError instead of the ValueError + raise TypeError('Enter only numbers') + # Print confirmation message if both values are numbers + else: + print(f'Both {x} and {y} are numbers.') + +#Call the numb_check function prompting for two numeric inputs and storing them in x and y vars +numb_check(x = input('Enter a number: '), y = input('Enter another number: '))