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?
2 Answers
+ 1
The second and third if statements should be elif statements.
All if, elif, and else statements must have the same level of indentation.
+ 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")