0
Does anyone know what’s wrong with this? It’s for the BMI calculator project. It says there is an invalid syntax in line 5
x = float(input()) y = float(input()) if x/y**2 < 18.5: print('Underweight') elif x/y**2 >= 18.5 and < 25.0: print('Normal') elif x/y**2 >= 25.0 and < 30.0: print('Overweight') else: print('Obesity')
3 Respostas
+ 2
elif x/y**2 >= 18.5 and < 25.0 :
^^^
Here is the error. You have to do the following :
elif x/y**2 >= 18.5 and x/y**2 < 25.0 :
+ 2
The previous comment have your answer.
But if you want to do it using less text first use a variable like: bmi, b etc. and insert the formula in it like: bmi = x/y**2
Now if you type 5th line like this: elif 18.5<=bmi<25:
it will also work the same.
0
Thank you. Both answers were very helpful.