fix(problem-04.py): completed problem

This commit is contained in:
baphim
2026-09-13 09:33:20 -04:00
parent 90a0ed05ae
commit b7f3993dd2
+15 -1
View File
@@ -2,4 +2,18 @@
# not numerical. # not numerical.
# Define the function to check if user input is a number # 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: '))