+ 1

Where did I go wrong? I need help please

height=float(input()) weight=float(input()) BMI=weight/(height**2) if BMI<18.5: print("Underwight") elif BMI>=18.5 and BMI<25: print("Normal") elif BMI>=25 and BMI<30: print("Overweight") else BMI=>30: print("Obesity")

2nd May 2021, 5:58 PM
Nafisa Mohamud
Nafisa Mohamud - avatar
11 odpowiedzi
+ 2
Error is line 10 Use elif condition not else For example. elif BMI >= 30: print("Obesity")
3rd May 2021, 10:34 AM
Code_lover
Code_lover - avatar
+ 2
You have to take only height as float values, weight is in integer i.e weight =Int(input()) height=float(input()) BMI=weight/float(height**2) Also last condition should be: elif BMI>=30:
3rd May 2021, 1:07 PM
Durga Devi
Durga Devi - avatar
+ 1
Nafisa Mohamud Try this: #your code goes here weight = int(input()); height = float(input()); bmi = weight/float(height*height); 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')
3rd May 2021, 10:33 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
0
It shows invalid syntax
2nd May 2021, 8:29 PM
Nafisa Mohamud
Nafisa Mohamud - avatar
0
Yes, I know. It's because of space. Replace the: "_" with tab or space.
2nd May 2021, 8:30 PM
Daniel Briceño
Daniel Briceño - avatar
0
Sorry but which space i don't get it
2nd May 2021, 8:32 PM
Nafisa Mohamud
Nafisa Mohamud - avatar
0
Don't worry, I am sure that someone will definaltely help you
4th May 2021, 2:10 PM
Uchiha Itachi
Uchiha Itachi - avatar
0
Satish Singh My code is running perfectly. It is working.
4th May 2021, 3:08 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
0
i am new here hey can somebody tell me what wrong thing did i do in this weight_as_int = int (weight) height_as_float= float (height) weight = int(input()); height = float(input()); bmi = weight/float(height*height); if bmi<18.5: print('Underweight') elif bmi>=18.5 and bmi<25: print("Normal") elif bmi>=25 and bmi<30: print('Overweight')
4th Aug 2024, 5:34 AM
techie
- 1
In the last else you must place: elif BMI >= 30: _#If is greater than or equal 30 then print("Obesity"); _print("Obesity"); or else: _#if not is less 30 then print("Obesity"); _print("Obesity"); #The two ways will bring you the same results
2nd May 2021, 6:32 PM
Daniel Briceño
Daniel Briceño - avatar
- 1
In python, blocks are identified using tab or space. While in other languages ​​it is used: {}. Example: in python: for i in range(0,10): _print("Hello, work"); print("end"); https://code.sololearn.com/cVALL3JtXzYV/?ref=app in C: #include <stdio.h>//printf int main(){ for (int i=0;i<10;i++){//i is interger so it is declared as int printf("Hello, work"); } printf("End"); return 0; } https://code.sololearn.com/cX5cMb5Vv6zu/?ref=app
2nd May 2021, 8:34 PM
Daniel Briceño
Daniel Briceño - avatar