Question #6 of Medical Insurance Project

Hello All. Brand new to the forum. On the DA path right now, and in the middle of my first project. At Question 5 in the Medical Insurance cost it’s telling me to calculate the difference between new_insurance_cost and insurance_cost and set it equal to change_in_insurance_cost, however, I get this print out:

change_in_insurance_cost = new_insurance_cost - insurance_cost
TypeError: unsupported operand type(s) for -: ‘str’ and ‘float’

What am I missing? Thanks in advance!

Hello and welcome to the forums!

What that error is telling you is that one of the variable is a string, while the other is a float. Since you can’t subtract a float from a string or vice-versa it throws the error.

You can check the type of both variables with print(type(var_name)) to find out which one is a string, then cast it to a float with float(var_name)

Happy coding!

1 Like