feat: attempted problem-04

This commit is contained in:
baphim
2026-09-12 21:01:33 -04:00
parent 93f889de42
commit 8fb61a1dd4
+15 -1
View File
@@ -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 # Write a Python program that prompts the user to input two numbers and raises a TypeError exception if the inputs are
# not numerical. # 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: "))