feat: attempted problem-04
This commit is contained in:
+15
-1
@@ -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.
|
||||
# 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: "))
|
||||
Reference in New Issue
Block a user