- 1

Need help with BMI calculator

Edit: I got it. I needed to ask for weight first, then for height. Hi, I need some help with an issue in my code. It passes test 1, but in test 2, for some reason my code still outputs "Underweight", when "Obese" is expected. I tried to change the else statement at the end to "elif x >= 30", same issue. I tried to change "height ** 2" to "height * height", same issue. I don't see where the bug is. Here's my code: height = float(input()) weight = float(input()) x = weight / (height ** 2) if x < 18.5: print("Underweight") elif x >= 18.5 and x < 25: print("Normal") elif x >= 25 and x < 30: print("Overweight") else: print("Obese") Thanks in advance :).

28th Jul 2022, 11:24 AM
bcherina
2 Respostas
+ 4
What order is the input. Do they give you first the weight or the height. In my BMI I get this as sample input: Sample Input 85 1.9 Weight first.
28th Jul 2022, 11:40 AM
Paul
Paul - avatar
+ 1
Also, please check the task description: It is "Obesity", not "Obese".
28th Jul 2022, 11:44 AM
Lisa
Lisa - avatar