can anybody notice any syntax error at the “elif bmi_value < 18.5:” statement?

def analyze_smoker(smoker_status):

if smoker_status == 1:

`````` print("To lower your cost, you should consider quitting smoking")
``````

else:

``````print("Smoking is not an issue for you")
``````

def analyze_bmi(bmi_value):

if bmi_value > 30:

``````print("Your BMI is in the obese range. To lower your cost, you should significantly lower your BMI.")
``````

elif 25 <= bmi_value <= 30:

``````print("Your BMI is in the overweight range. To lower your cost, you should lower your BMI.")

print("you need to lower your BMI by " + str(round(bmi_value - 24))
``````

elif bmi_value < 18.5:

``````print("Your BMI is in the underweight range. Increasing your BMI will not help lower your cost, but it will help improve your health.")
``````

# Function to estimate insurance cost:

def estimate_insurance_cost(name, age, sex, bmi, num_of_children, smoker):

estimated_cost = 250age - 128sex + 370bmi + 425num_of_children + 24000*smoker - 12500

print(name + “'s Estimated Insurance Cost: " + str(estimated_cost) + " dollars.”)

try:

``````analyze_smoker(smoker)

analyze_bmi(bmi)
``````

except:

``````print("error occurred")
``````

return estimated_cost

# Estimate Keanu’s insurance cost

keanu_insurance_cost = estimate_insurance_cost(name = ‘Keanu’, age = 29, sex = 1, bmi = 26.2, num_of_children = 3, smoker = 1)

my_insurance_cost = estimate_insurance_cost(name = “Shibalik”, age = 26, sex = 1, bmi = 24, num_of_children = 0, smoker = 1)

Please see How do I format code in my posts? as the forums strip most of the formatting from posted code otherwise which makes it very hard to hard. If you can’t spot an error on that exact line try viewing the lines before it, a common source of syntax errors in Python is unclosed parentheses or similar.

``````def analyze_smoker(smoker_status):
if smoker_status == 1:
print("To lower your cost, you should consider quitting smoking")
else:
print("Smoking is not an issue for you")

def analyze_bmi(bmi_value):
if bmi_value > 30:
print("Your BMI is in the obese range. To lower your cost, you should significantly lower your BMI.")
elif 25 <= bmi_value <= 30:
print("you need to lower your BMI by " + str(round(bmi_value - 24))
elif bmi_value < 18.5:
print("Your BMI is in the underweight range. Increasing your BMI will not help lower your cost, but it will help improve your health.")

# Function to estimate insurance cost:
def estimate_insurance_cost(name, age, sex, bmi, num_of_children, smoker):
estimated_cost = 250*age - 128*sex + 370*bmi + 425*num_of_children + 24000*smoker - 12500
print(name + "'s Estimated Insurance Cost: " + str(estimated_cost) + " dollars.")
try:

analyze_smoker(smoker)
analyze_bmi(bmi)
except:
print("error occurred")
return estimated_cost

# Estimate Keanu's insurance cost
keanu_insurance_cost = estimate_insurance_cost(name = 'Keanu', age = 29, sex = 1, bmi = 26.2, num_of_children = 3, smoker = 1)

my_insurance_cost = estimate_insurance_cost(name = "Shibalik", age = 26, sex = 1, bmi = 24, num_of_children = 0, smoker = 1)
``````

Have you checked the previous lines as mentioned in the last message?

Hi…thanks for pointing out, it was an unclosed bracket indeed in the previous line…

1 Like