+ 2
Can I get help with this code?
#your code goes here weight = int(input ()) height = float(input()) BMI = int(weight/height*height) if BMI <18.5: print ("Underweight") elif BMI>=18.5 and BMI<25: print ("Normal") elif BMI>=25 and BMI<30: print ("Overweight") elif BMI>=30: print ("Obese")
3 Answers
+ 5
You have 2 problems:
1. Nesting, your elif need to be at same nesting level as if
if BMI < 18.5:
print ("Underweight")
elif BMI >= 18.5 and BMI < 25:
print ("Normal")
2. Your formula for BMI is wrong, it is: weight / (height * height)
In your formula it will follow math operations and do first weight / height and then multiply result by height what give wrong BMI
0
I did this a few days ago, along with nesting and formula I had to put >0 and < 18.5