- 2

What's wrong with this code

#BMI CALCULATOR weight = int(input("in Kg:")) height = float(input("in meters:")) BMI=(weight /(height **2)) print(BMI) if (BMI < 18.5): print ("Underweight") else: if BMI >= 18.5 and < 25: else: print ("Normal") else: if (BMI >= 25 and < 30): print ("Overweight") else: if (BMI>= 30): print ("Obesity")

22nd May 2022, 1:12 PM
Aliyu Tukur
Aliyu Tukur - avatar
4 ответов
+ 2
Click on your "bmi" tag and you'll see hundreds of replies.☺️
22nd May 2022, 2:22 PM
Solo
Solo - avatar
+ 2
I think there are a few issues with your "if/else/if" lines. You probably want to re-read that section of the tutorial. I think it should look like: if (condition) //code elif (condition) //code else //code
22nd May 2022, 4:02 PM
Ausgrindtube
Ausgrindtube - avatar
0
instead of: and < you should write: and BMI < Also delete every line that has "else:". And fix the indentation - each (of the remaining) lines that ends in ":" should be followed by an indented line. Like this: if (BMI < 18.5): print ("Underweight") if BMI >= 18.5 and BMI < 25: print ("Normal") if (BMI >= 25 and BMI < 30): print ("Overweight") if (BMI>= 30): print ("Obesity") It's not the best, but it should work as intended.
22nd May 2022, 7:09 PM
lion
lion - avatar
- 1
weight = float(input('')) height = float(input('')) 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')
12th Jun 2022, 3:36 AM
Nícolas Nascimento
Nícolas Nascimento - avatar