+ 1
Can someone please explain why this isn't working?
Can some pls explain why this code isn't working? I know I am an amature so it may have a lot of problems lol But why isn't it working? https://code.sololearn.com/clPipht2D9Wz/?ref=app
7 Answers
+ 4
You must specify what you are comparing in order to complete the boolean expression.
elif user_bmi >= 18.5 or < 25:
Should be:
elif user_bmi >= 18.5 or user_bmi < 25:
Also, there is no need to check if user_bmi >= 18.5 since at this point in the logic you already established that it is not < 18.5. Now you only need to check if it is < 25.
if user_bmi < 18.5:
print("Underweight")
elif user_bmi < 25:
print("Normal")
The same improvement applies to the 30 threshold. The final elif should be a simple else.
+ 7
Preeyansh Tibrewal ,
there is also a issue with the logical operator in the conditional statements.
we can not use *or* to build this logic, it needs to be *and* . to reduce the confusion, here is the complete code:
weight = int(input())
height = float(input())
user_bmi = weight / height ** 2
if user_bmi < 18.5:
print("Underweight")
elif user_bmi >= 18.5 and user_bmi < 25:
print("Normal")
elif user_bmi >= 25.0 and user_bmi < 30:
print("Overweight")
elif user_bmi >= 30.0:
print("Obesity")
+ 7
Preeyansh Tibrewal ,
that is great, congratulations !!!
+ 2
Lothar Yes that was an issue too but I can proudly say that I figured it out myself yesterday đ€
+ 1
Input weight first, then height.
+ 1
It had some other smaller issues too
Had to take some time to solve it
But that's what helps me improve!
0
It says syntax error in line 6 Brian