Help - Python Syntax: Medical Insurance Project

Hello Everyone,

I am new to coding and I am stuck at Python Syntax: Medical Insurance Project. I will really appreciate your guidance.

# create the initial variables below num_of_children = "2" # Add insurance estimate formula below # Age Factor age = "39" bmi = "27.3" sex = "0" # Extra Practice smoker = "1" insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500 print = ("This person's insurance cost is" + str(insurance_cost) + "dollars.")

I keep getting this error.

Traceback (most recent call last):
File “script.py”, line 17, in
insurance_cost = 250 * age - 128 * sex + 370 * bmi + 425 * num_of_children + 24000 * smoker - 12500
TypeError: unsupported operand type(s) for -: ‘str’ and ‘str’

Kind regards,
Sultan.

Hello @sultanmuhammad790189 ,

Welcome! Try assigning numbers instead of strings to the variables. Instead of a="5" try a=5. Also, check the syntax on your print statement.

Thanks for including your Codebyte! It would be super helpful if you include the link to your exercise too :slight_smile:

2 Likes

Thank you very much. I am getting a new error now. I am a bit confused :frowning:

1 Like

Can you post your new error? We’ll try to help you.