feat(problem-04.py): another attempt
This commit is contained in:
@@ -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
|
# 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):
|
def numb_check(n):
|
||||||
|
while True:
|
||||||
try:
|
try:
|
||||||
result = x * y
|
numb = float(input(n))
|
||||||
except TypeError:
|
except ValueError:
|
||||||
print(f"Either {x} and/or {y} are not numbers.")
|
print(f"{numb} is not a number")
|
||||||
|
|
||||||
|
|
||||||
numb_check(x = input("Enter a number: "), y = input("Enter another number: "))
|
x = numb_check(input('Enter a number: '))
|
||||||
|
y = numb_check(input('Enter another number: '))
|
||||||
|
product = x * y
|
||||||
|
print(product)
|
||||||
Reference in New Issue
Block a user