Why my code is not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
11th Apr 2021, 12:18 PM
Akash Prasad
Akash Prasad - avatar
6 Answers
+ 4
Try using float and see if it would work
12th Apr 2021, 6:04 AM
Pro Professor
Pro Professor - avatar
+ 1
Because you are not printing correct thing. Secondly use float instead of int
11th Apr 2021, 12:27 PM
CHANDAN ROY
CHANDAN ROY - avatar
+ 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')
11th Apr 2021, 12:33 PM
Akash Prasad
Akash Prasad - avatar
+ 1
Now is it ok
11th Apr 2021, 12:34 PM
Akash Prasad
Akash Prasad - avatar
+ 1
Going to my desktop to check
11th Apr 2021, 12:37 PM
Akash Prasad
Akash Prasad - avatar
+ 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
11th Apr 2021, 12:39 PM
CHANDAN ROY
CHANDAN ROY - avatar