# Medical Insurance Project Part 10 (extra task)

Hello,
I have been stuck on this problem for quite a bit now and cant seem to figure it out.
I am trying to solve this problem:

“In your `analyze_bmi()` function, notify the individual how much they need to lower their BMI to bring it to a normal weight range.”
(link at bottom of post)

``````
```# Analyzing insurance cost for BMI
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.")
if bmi_value >= 25:
return bmi_value
high_bmi = bmi_value - 25
print("You can lower your cost by lowering your BMI by " + str(high_bmi) + " points.")
elif bmi_value >= 25 and bmi_value <= 30:
print("Your BMI is in the overweight range. To lower your cost, you should lower your BMI.")
elif bmi_value >= 18.5 and bmi_value < 25:
print("Your BMI is in a healthy range.")
else:
print("Your BMI is in the underweight range. Increasing your BMI will not help lower your cost, but it will help improve your health.")
``````

I am aware that the first `elif` statement will not work when the previous `if` statement conditions are met.

I attempted to make a new `if` statement that will take all `bmi_value` higher than 25 and subtract 25 from it, creating a new variable, `high_bmi`. Then I attempted to make the string read `"You can lower your cost by lowering your BMI by " + str(high_bmi) + " points."`
The variable `high_bmi` should hold the value of `bmi_value - 25` which would be how much they need to lower it by.

kind of at a dead end here and not sure what else to try!

Thank you in advance for any help!

Python Control Flow | Codecademy

Check the order and nesting of your logic statements. If you want this value to be available to every possible clause then consider where it should be calculated and assigned.

i moved the variable to the top of the function instead of being within the conditional statement and moved a few things around and was able to get it to work!

``````# Analyzing insurance cost for BMI
def analyze_bmi(bmi_value):
bmi_adjustment = bmi_value - 25
if 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.")
elif bmi_value >= 18.5 and bmi_value < 25:
print("Your BMI is in a healthy range.")
elif bmi_value >= 25 and bmi_value <= 30:
print("Your BMI is in the overweight range. To lower your cost, you should lower your BMI by " + str(bmi_adjustment) + " points.")
else:
print("You are obese. You can lower your cost by lowering your BMI by " + str(bmi_adjustment) + " points.")
``````