Python Forum
Manually raising two error types with a function that computes sqfeet to sqmeters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manually raising two error types with a function that computes sqfeet to sqmeters
#1
I keep getting TypeError: unsupported operand type(s) for /: 'str' and 'float'. How do I manage to raise the errors successfully as well as removing this reoccurring TypeError? Please help!!! Thank you in advance!!

def sqfeet_to_sqmeters(a_value):
    answer_in_sqmeters = a_value / 10.764 ** 2
    try:
        if type(a_value) == float:
            return answer_in_sqmeters
    except:
        try:
            if type(a_value) != float:
                raise TypeError(ERROR_NAN)
        except TypeError:
            if a_value < 0:
                raise ValueError(ERROR_NEGATIVE)
a_value = input("Enter area in square feet: ")
print(sqfeet_to_sqmeters(a_value))
Reply


Messages In This Thread
Manually raising two error types with a function that computes sqfeet to sqmeters - by sean1 - Nov-11-2021, 10:34 PM
Raising Errors - by sean1 - Nov-12-2021, 01:30 AM
RE: Raising Errors - by deanhystad - Nov-12-2021, 02:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  a generator that computes squares of first 20 natural numbers mdshamim06 1 8,992 Oct-01-2019, 10:38 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020