+ 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
2 Answers
+ 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..
+ 1
Thank you @Jayakrishnain for your answer. It worked!!