Nov-12-2021, 01:30 AM
(This post was last modified: Nov-12-2021, 07:57 AM by Yoriz.
Edit Reason: Added error tags
)
How am I able to raise the TypeError when entering a non numerical input? Because of the float(input .... in line 8 a value error is automatically raised. Thanks!
# Area Unit Converter from configuration import ERROR_NEGATIVE, ERROR_NAN RATIO_M2F = 10.764 # LIBRARY: function declaration part # put definitions of functions here a_value = float(input("Enter area in square feet: ")) def check_one(a_value): if float(a_value) < 0: raise ValueError(ERROR_NEGATIVE) elif type(a_value) != float: raise TypeError(ERROR_NAN) def sqfeet_to_sqmeters(a_value): check_one(a_value) return a_value / RATIO_M2F ** 2 check_one(a_value) print(sqfeet_to_sqmeters(a_value))