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')

24th Jul 2021, 2:54 AM
Zack Jr.
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 :
24th Jul 2021, 3:53 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 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.
24th Jul 2021, 6:18 AM
Ehosanul Haque
Ehosanul Haque - avatar
0
Thank you. Both answers were very helpful.
25th Jul 2021, 1:34 AM
Zack Jr.