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: '))