0

Help with python 26 code project

Question asks me to make a BMI calculator and the first two test inputs pass but the other three are failures. However, it’s locked and I can’t see what’s wrong. Here’s my code: weight = int(input()) height = float(input()) BMI = weight / height**2 if BMI < 18.5: print("Underweight") if BMI >= 18.5 and BMI < 25: print("Normal") if BMI >= 25 and BMI < 30: print("Overweight") else: print("Obesity") It looks fine to me but it’s apparently wrong?

2nd Sep 2021, 9:29 PM
Iso_Aku
2 Respuestas
+ 1
The second and third if statements should be elif statements. All if, elif, and else statements must have the same level of indentation.
2nd Sep 2021, 9:35 PM
Simon Sauter
Simon Sauter - avatar
+ 5
w= int(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")
18th Nov 2021, 5:25 PM
Callie Schwieder