Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
0
When writing a code in python always take proper care of idendation And here u made mistakes in the condition checking and took string input() for height weight = int(input()) height = int(inptut()) X = weight/height*2 if x < 18.5 : print (" underweight") elif x > 18.5 and x < 25: print ("normal") elif x > 25 and x < 30: print ("overweight") elif x > 30 print (" obesity") since your are checking x with a floating point value u can also get input as weight = float(input()) height = float(input())
17th Sep 2021, 9:04 AM
Niththish
Niththish - avatar
0
That is the right code ???
17th Sep 2021, 9:05 AM
Abhishek Dey
0
weight = int(input()) height = float(input()) x = weight/height**2 if x < 18.5 : print ("Underweight") elif 18.5 <= x < 25: print ("Normal") elif 25 <= x < 30: print ("Overweight") elif 30 <= x: print ("Obesity")
17th Sep 2021, 11:52 AM
Simba
Simba - avatar
0
weight = int(input()) height = float(input()) x = weight/height**2 if x < 18.5 : print ("Underweight") elif 18.5 <= x < 25: print ("Normal") elif 25 <= x < 30: print ("Overweight") elif 30 <= x: print ("Obesity") I am try this code but not working
17th Sep 2021, 12:21 PM
Abhishek Dey
0
Try this it will be of great help #Do well to observe all these steps next time as they are vital weight = float(input("Enter your weight: ")) height=float(input("Enter your height: ")) x= weight/(height*2) if x<18.5: print ( f" your weight is {x} ,and you are underweight") elif 18.5< x<25: print (f"You are normal,your weight is {x}") elif 25<=x<30: print (f"You are overweight, your weight is {x}") elif x>=30: print (f"You are obese, your weight is {x}. You do need to slim down")
18th Sep 2021, 12:51 AM
Joseph Edet
Joseph Edet - avatar
0
Try again
18th Sep 2021, 5:43 AM
Simba
Simba - avatar
0
Be careful with the indentation, the spelling and the syntax Indentation - all commands that relate to the if, else, elif statements must be indented or else the code won't know where the if condition ends Spelling- input not inptut Syntax - elif statements must end with a colon(:) - your first does, next two dont. Hope these tips help!
18th Sep 2021, 9:36 PM
Andrew Turvey
0
Abhishek Dey Your question appears to a duplicate please use the searchbar before asking. Please use the forum guidelines provided below and use the 8 rules for getting help from the community. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community Your question will be marked for deletion. Reason duplicate threads are removed to: Focus substantially similar discussion in one thread and to prevent forums being cluttered with multiple threads on the same topic. https://www.sololearn.com/Discuss/1316935/?ref=app https://www.sololearn.com/discuss/2687547/?ref=app https://www.sololearn.com/discuss/2748154/?ref=app https://www.sololearn.com/discuss/2686011/?ref=app https://www.sololearn.com/discuss/2750158/?ref=app https://www.sololearn.com/discuss/2686226/?ref=app https://www.sololearn.com/discuss/2771623/?ref=app
19th Sep 2021, 2:41 AM
BroFar
BroFar - avatar