+ 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")

21st Dec 2022, 7:59 PM
Tiffany Awuor
Tiffany Awuor - avatar
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
21st Dec 2022, 8:40 PM
PanicS
PanicS - avatar
0
I did this a few days ago, along with nesting and formula I had to put >0 and < 18.5
23rd Dec 2022, 6:32 PM
Oddly Satisfying
Oddly Satisfying - avatar