diff --git a/lab-02/problem-04.py b/lab-02/problem-04.py index 2ce7773..06b6271 100644 --- a/lab-02/problem-04.py +++ b/lab-02/problem-04.py @@ -1,2 +1,16 @@ # Write a Python program that prompts the user to input two numbers and raises a TypeError exception if the inputs are -# not numerical. \ No newline at end of file +# not numerical. + +def numb_check(x, y): + try: + # Try if both values entered are numbers + x == float(x) + y == float(y) + # Print a confirmation message + print(f"Correct. Both {x} and {y} are numbers.") + except TypeError: + # Print message stating one or both values entered are not numbers + print(f"Either {x} and/or {y} is not a number.") + +# Call the numb_check function and prompt user for input +numb_check(x = input("Enter a number: "), y = input("Enter another number: ")) \ No newline at end of file