fix(problem-04.py): completed problem
This commit is contained in:
+15
-1
@@ -2,4 +2,18 @@
|
||||
# not numerical.
|
||||
|
||||
# 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: '))
|
||||
|
||||
Reference in New Issue
Block a user