Unknown error in BMI calculator code. How I can fix it??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Unknown error in BMI calculator code. How I can fix it???

BMI Calculator code #Unknown error in line 6 weight = float(input('')) height = float(input('')) bmi = weight/(height*height) if (bmi < 18.5): print ('Underweight') elif (bmi >= 18.5 and < 25): print ('Normal') elif (bmi >= 25 and < 30): print ('Overweight') elif (bmi <= 30): print ('Obesity')

6th Apr 2021, 8:20 PM
Bohdan 2751
Bohdan 2751 - avatar
4 Answers
+ 2
hi! try to place all the ifs and elifs in one column strictly under each other. in python, spaces have values
6th Apr 2021, 8:29 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
after the logical "and" operator, you need to substitute a variable with which you compare the number 25
6th Apr 2021, 8:36 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Or use this way: (18.5 <= bmi < 25)
6th Apr 2021, 8:37 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
New error, line 5
6th Apr 2021, 8:32 PM
Bohdan 2751
Bohdan 2751 - avatar