From 1e4e0fe72d1219bcb238500bb4bf8fdbb3855d46 Mon Sep 17 00:00:00 2001 From: baphim <269010393+baphim@users.noreply.github.com> Date: Sun, 13 Sep 2026 08:36:30 -0400 Subject: [PATCH] feat(problem-04.py): another attempt --- lab-02/problem-04.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lab-02/problem-04.py b/lab-02/problem-04.py index 672cb04..f73fbfc 100644 --- a/lab-02/problem-04.py +++ b/lab-02/problem-04.py @@ -1,11 +1,15 @@ # Write a Python program that prompts the user to input two numbers and raises a TypeError exception if the inputs are # not numerical. -def numb_check(x, y): - try: - result = x * y - except TypeError: - print(f"Either {x} and/or {y} are not numbers.") +def numb_check(n): + while True: + try: + numb = float(input(n)) + except ValueError: + print(f"{numb} is not a number") -numb_check(x = input("Enter a number: "), y = input("Enter another number: ")) \ No newline at end of file +x = numb_check(input('Enter a number: ')) +y = numb_check(input('Enter another number: ')) +product = x * y +print(product) \ No newline at end of file