+ 3

please what is wrong with this code?. I dont understand

height=float(input()) weight=float(input()) BMI=(weight/(height**2)) if BMI<18.5: print ("underweight") elif BMI>=18.5 and BMI<25: print ("normal") elif BMI>=25 and BMI<30: print ("overweight") else BMI>=30: print ("obesity") print(BMI)

9th Jan 2023, 7:17 AM
Damian
43 Respostas
+ 12
Else statements shouldn't be written with any condition.
10th Jan 2023, 3:31 PM
NIKHIL KUMAR SINHA
NIKHIL KUMAR SINHA - avatar
+ 7
The final correction is to match capitalization with the output that is shown in the task. Code Coach is case-sensitive.
9th Jan 2023, 7:45 AM
Brian
Brian - avatar
+ 5
height = float(input()) weight = float(input()) BMI = (weight / (height ** 2)) if BMI < 18.5: print("underweight") elif BMI >= 18.5 and BMI < 25: print("normal") elif BMI >= 25 and BMI < 30: print("overweight") else: print("obesity") print(BMI)
9th Jan 2023, 4:40 PM
Mwanzi Victor
Mwanzi Victor - avatar
+ 2
Please show the latest code.
9th Jan 2023, 7:52 AM
Brian
Brian - avatar
+ 2
Glory please do not post off topic. You may start a new question for help with a different problem.
10th Jan 2023, 8:59 PM
Brian
Brian - avatar
+ 2
I think the mistake is in putting a condition to else
10th Jan 2023, 11:07 PM
Catherine Echemendia HernƔndez
Catherine Echemendia HernƔndez - avatar
+ 1
Inputs are in wrong order.
9th Jan 2023, 7:20 AM
Brian
Brian - avatar
+ 1
how
9th Jan 2023, 7:31 AM
Damian
+ 1
Code Coach provides weight first, then height. See the example provided in the task description.
9th Jan 2023, 7:33 AM
Brian
Brian - avatar
+ 1
ok tenx the code works but its still not correct
9th Jan 2023, 7:41 AM
Damian
+ 1
ok corrected but its still not correct
9th Jan 2023, 7:50 AM
Damian
+ 1
You're right that it should only print the text. I overlooked the last line that prints BMI. Remove that line.
9th Jan 2023, 7:56 AM
Brian
Brian - avatar
+ 1
thank you so much
9th Jan 2023, 7:58 AM
Damian
+ 1
You're welcome! šŸ¤
9th Jan 2023, 8:00 AM
Brian
Brian - avatar
+ 1
We cannot write condition with else, You should use elif at the place of else or simply use else without condition šŸ‘
9th Jan 2023, 4:35 PM
Lokesh Soni
Lokesh Soni - avatar
+ 1
Me quedĆ© en el mismo ejercicio šŸ˜
10th Jan 2023, 12:22 AM
Yamila Cerdan
Yamila Cerdan - avatar
+ 1
Input are improper arrange
10th Jan 2023, 10:03 AM
Travis
Travis - avatar
+ 1
this one passes all 5 cases weight = int(input()) height = float(input()) BMI = weight/(height*height) 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")
10th Jan 2023, 3:23 PM
Travis
Travis - avatar
0
my output is both the string and the float
9th Jan 2023, 7:51 AM
Damian
0
its suppose to be just de string
9th Jan 2023, 7:51 AM
Damian