+ 3
Why my code is not working
6 ответов
+ 4
Try using float and see if it would work
+ 1
Because you are not printing correct thing. Secondly use float instead of int
+ 1
#your code goes here
weight=float(input('enter weight'))
height=float(input('enter height'))
BMI=weight/height**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')
+ 1
Now is it ok
+ 1
Going to my desktop to check
+ 1
Bro, your code is close to being a solution but you are making some silly mistakes.
I have removed those mistakes in your code and commented your errors. Here is the solution that works.
weight=float(input()) #remove strings inside input
height=float(input()) #remove strings inside input
BMI=weight/height**2
if BMI<18.5:
print('Underweight') #underweight is not same as Underweight
elif BMI>=18.5 and BMI<25:
print ('Normal') #normal is not same as Normal
elif BMI>=25 and BMI<30:
print('Overweight') #overweight is not same as Overweight
else:
print('Obesity') #obesity is not same as Obesity