+ 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")
11 Respuestas
+ 2
Error is line 10
Use elif condition not else
For example.
elif BMI >= 30:
print("Obesity")
+ 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:
+ 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')
0
It shows invalid syntax
0
Yes, I know. It's because of space.
Replace the: "_" with tab or space.
0
Sorry but which space i don't get it
0
Don't worry, I am sure that someone will definaltely help you
0
Satish Singh
My code is running perfectly.
It is working.
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')
- 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
- 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