0

Can someone tells me what's the wrong in this code

Bmi =int(input()) Bmi = weight / height**2 if Bmi<18.5 print(Underweight): else: if 18.5=<Bmi<25: print(Normal) else: if 25=<Bmi<30: print(Overweight) else: if Bmi<30 print(Obesity)

14th Sep 2022, 6:24 PM
Hanan Ahmed
4 Réponses
+ 3
Hi! most likely, you do not have enough gaps in the use of branch operators, the third and 12th lines of code lack a colon : put at least three spaces in front of the print operator in the fourth line, remove the extra colons: you are very inattentive in writing the code
14th Sep 2022, 6:45 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Where is weight and height defined?
14th Sep 2022, 8:06 PM
dan
dan - avatar
+ 2
``` def main(): height = float(input()) weight = float(input()) bmi = (weight / height ** 2) if (bmi < 18.5): wclass = ("Underweight") elif (bmi >= 18.5 and bmi < 25): wclass = ("Normal weight") elif (bmi >= 25 and bmi < 30): wclass = ("Overweight") elif (bmi > 30): wclass = ("Obese") print ("current bmi:", bmi) print ("weight catagory:", wclass) main() ``` I have changed the code ever so slightly, it now works. if you have any questions just let me know.
14th Sep 2022, 11:29 PM
Lauchlan Currie
Lauchlan Currie - avatar
+ 2
Thanks a lot for all🌻
15th Sep 2022, 3:07 AM
Hanan Ahmed