BMI | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

BMI

Hi, i m having troubles to pass the exercise. 4 out of 5 attemps are well done but don't know why si wrong weight = int(input()) height = float(input()) BMI = weight / (height**2) if (BMI<18.5): print ("Underweight") elif ((BMI >= 18.5) and (BMI <=24.9)): print ("Normal") elif ((BMI >=25) and (BMI <= 29.9)): print ("Overweight") elif (BMI >=30): print ("Obesity")

7th Apr 2021, 1:47 AM
Marcelo Grenat
Marcelo Grenat - avatar
4 Answers
+ 6
You need to change your 1st and 2nd elif statements. BMI<25 BMI<30
7th Apr 2021, 1:58 AM
Simba
Simba - avatar
+ 3
Thanks a Lot, that was the problema xD
7th Apr 2021, 2:00 AM
Marcelo Grenat
Marcelo Grenat - avatar
+ 2
This works #your code goes here w = float (input()) h = float (input()) bmi = w/h**2 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("Obesity")
23rd Apr 2021, 6:11 PM
Ale
Ale - avatar
+ 1
weight = int(input()) height = float(input()) bmi = weight/(height*height) if bmi <18.5: print('Underweight') elif bmi >30: print('Obesity') elif bmi <25 >18.5: print('Normal') elif bmi >25 <30: print('Overweight') this worked.
22nd Oct 2021, 10:56 AM
Saint Gaming
Saint Gaming - avatar