+ 1

Can anyone help me discover what's wrong with this code?

I have to calculate the BMI, but one of the test cases is not good. Here are the instructions and my code: The resulting number indicates one of the following categories: Underweight = less than 18.5 Normal = more or equal to 18.5 and less than 25 Overweight = more or equal to 25 and less than 30 Obesity = 30 or more Let’s make finding out your BMI quicker and easier, by creating a program that takes a person's weight and height as input and outputs the corresponding BMI category. https://code.sololearn.com/cbh6qcFcRCdc/?ref=app

18th Dec 2022, 2:45 AM
Mar🌷✨️
Mar🌷✨️ - avatar
1 Answer
+ 4
In your if conditions you should respect the same limits as given in the text. Instead of BMI <= 24.9 Use BMI < 25 Also you are double checking some conditions in 'elif' which are obviously true, it is not an error but is redundant. For example after you check BMI < 18.5 In the next elif you don't need to specify BMI >= 18 because that is going to be trivially true anyway. You can change the last elif to "else" without any conditions (it covers all the numbers that were not captured by previous if elif branches).
18th Dec 2022, 3:27 AM
Tibor Santa
Tibor Santa - avatar