+ 1

Can someone tells me what im doing wrong here

In comment

7th Mar 2021, 10:24 AM
Him8=)
Him8=) - avatar
12 odpowiedzi
+ 9
1) You need to use indentations inside the if statements 2) weight = float(int()) is not valid. Use float(input()) as you want to get input and convert it to float 3) else can't have a condition 4) it should be < than 25 (line 7). 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')
7th Mar 2021, 10:33 AM
Artem 🇺🇦
Artem 🇺🇦 - avatar
+ 7
The thing you're doing wrong is not sharing your code.
7th Mar 2021, 10:26 AM
Artem 🇺🇦
Artem 🇺🇦 - avatar
+ 6
Phan The 1. Intdentation Error: if statement: yourCode -> causes an error if statement: yourCode -> yourCode belongs now to the if statement 2. = vs == = assign a value to a variable == check if to values are equal 3. check the last else statement. I suggest you to read in the lesson about if else
7th Mar 2021, 10:34 AM
Denise Roßberg
Denise Roßberg - avatar
+ 3
#your code goes here , corected code read comments.. Just removed errors, may not a complete solution..Phan The weight = float(input()) height = float(input()) #use input(),not int() bmi=weight/(height**2) if bmi < 18.5: print('Underweight') elif bmi >= 18.5 and bmi < 25: #use < or <= or ==, not =. # = assignment operator, not comparision opearator, use <,<=, or == print('Normal') elif bmi >= 25 and bmi < 30: print('Overweight') elif bmi >= 30: # missing : print('Obesity')
7th Mar 2021, 10:34 AM
Jayakrishna 🇮🇳
+ 3
There were a number of mistakes including indentation and input syntax. Also one operator problem, and invalid ELSE syntax. Please review adjusted code #your code goes here weight = float(input()) # kgs height = float(input()) # metres 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')
7th Mar 2021, 10:39 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
^^ Thank
7th Mar 2021, 11:43 AM
Him8=)
Him8=) - avatar
+ 2
Hello Phan The At the moment your question is incomplete because you need to share your code. Otherwise we can't help you.
7th Mar 2021, 10:27 AM
Denise Roßberg
Denise Roßberg - avatar
+ 2
Use indentation. The print statements should be inside the if clause, so must be indented. To read a number use int(input()) or float(input()) The description of the problem you are referring to (BMI calculator) would make it easier to help you
7th Mar 2021, 10:37 AM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Phan The Single equal (=) used for assignment. To compare values you need to use double equal (==)
7th Mar 2021, 10:48 AM
A͢J
A͢J - avatar
+ 2
You don't need these pieces: "bmi >= 18.5 and" "bmi >= 25 and" "bmi >= 30" They are all redundant. For example, once you've determined that bmi isn't less than 18.5, then it must be greater than or equal to 18.5. No need to test for it.
8th Mar 2021, 5:25 PM
Steve
Steve - avatar
+ 1
Yep u right https://code.sololearn.com/c434qoYPCbvh/?ref=app Can someone ans pls
7th Mar 2021, 10:27 AM
Him8=)
Him8=) - avatar
0
Phan The Trt 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')
8th Mar 2021, 7:03 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar