Bmi calculator error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Bmi calculator error

w=int(input()) h=float(input()) bmi= w / (h*h) if bmi< 18.5: print ("Underweight") elif bmi<= 18.5 and bmi< 25.0: print ("Normal") elif bmi>=25.0 and bmi<30.0: print ("Overweight") else: print ("Obesity")

18th Mar 2022, 6:28 PM
Ace Coder
Ace Coder - avatar
2 Answers
+ 3
Should be elif bmi >= 18.5 and bmi< 25.0
18th Mar 2022, 8:15 PM
Monica Garcia
Monica Garcia - avatar
+ 5
As has been pointed out, the <= should be >=. There is no need to test >= after you already tested <. Just remove the redundant logic and mistakes like that won't happen. w=int(input()) h=float(input()) bmi= w / (h*h) if bmi< 18.5: print ("Underweight") elif bmi< 25.0: print ("Normal") elif bmi<30.0: print ("Overweight") else: print ("Obesity")
18th Mar 2022, 8:46 PM
Brian
Brian - avatar