+ 1

BMI calculator

Hello Everyone, I'm trying to do the BMI calculator, but I don't know what I'm doing wrong. My code is the following: 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") else: print("Obesity") and the error is: File "/usercode/file0.py", line 6 elif (bmi>=18.5 and bmi<25): ^ SyntaxError: invalid syntax Can anyone help me please? Thanks in advance

3rd Jul 2022, 9:29 AM
Catalina Cardozo
Catalina Cardozo - avatar
2 ответов
+ 5
Wrong Identation ... Your elif not belong to any if block.. So it's 'else without if' invalid. if condition : #no space before if # if block code elif condition : #same space as same for if # elif block code ... Ident your elif with same identation with if block.. And bmi >= 30 must output obesity..
3rd Jul 2022, 9:53 AM
Jayakrishna 🇮🇳
+ 1
Thank you @Jayakrishnain for your answer. It worked!!
3rd Jul 2022, 11:33 AM
Catalina Cardozo
Catalina Cardozo - avatar