0

Line 6 , invalid syntax. What i forgot😱??

weight = int(input()) height = float(input()) index = weight * height if index <= 18.5: print("Underweight") elif index <= 18.5 or => 24.9: print("Normal") elif index <= 25.0 or => 29.9: print("Overweight") elif index >=30.0: print("Obesity")

7th Jun 2021, 8:28 PM
Расим Багиров
Расим Багиров - avatar
10 Réponses
+ 7
Расим Багиров , some issues in your code. you should read the task description more carefully. the code snippet below is reworked and shows corrections. (1) wrong formula for bmi calculation (2) incorrect definition of lower and upper limit of numbers (3) wrong logical operator ... index = weight / (height**2) # (1) if index < 18.5: print("Underweight") elif index >= 18.5 and index < 25: #(2), (3) ... this is the same for the rest of the code happy coding and good success!
7th Jun 2021, 9:27 PM
Lothar
Lothar - avatar
+ 4
(Расим Багиров ) Luke Morrison , you are absolutely right. the indentation for the code shown (now) from Расим Багиров is not correct. the initial code that was shown here, was correct in indentation. it should be reworked.
8th Jun 2021, 9:54 AM
Lothar
Lothar - avatar
+ 2
Thank you so much!!😱 Now ,when i look for right code , i understand where i make mistakes))
7th Jun 2021, 9:38 PM
Расим Багиров
Расим Багиров - avatar
+ 1
Is the indentation correct? Shouldn't the elif statements be on the same level as the if statements?
8th Jun 2021, 9:37 AM
Luke Morrison
+ 1
Расим Багиров You still have a number of mistakes but you are getting closer. first syntax error: elif index >= 18.5 and index < 24.9 See if you can find the other syntax problem. The other problem will involve correct outputs. Please refer to the description: The resulting number indicates one of the following categories: Underweight = less than 18.5 Normal = more or equal to 18.5 and less than 25 Overweight = more or equal to 25 and less than 30 Obesity = 30 or more Try testing you code using 30 as a BMI. There is one other similar fault. Happy bug hunting
8th Jun 2021, 7:20 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 1
Finally i see other code and understand, need connect " index" after " and".))))
8th Jun 2021, 8:00 PM
Расим Багиров
Расим Багиров - avatar
0
Still not work
7th Jun 2021, 8:46 PM
Расим Багиров
Расим Багиров - avatar
0
Somebody help!!!
7th Jun 2021, 8:50 PM
Расим Багиров
Расим Багиров - avatar
0
height * height
7th Jun 2021, 9:20 PM
Rik Wittkopp
Rik Wittkopp - avatar
0
I change formula. Change lower upper limit, change "or" for "and". But now : invalid syntax on line 6. Here new changed code. 👇 What else? weight = int(input()) height = float(input()) index = weight /(height**2) if index < 18.5: print("Underweight") elif index >= 18.5 and < 24.9: print("Normal") elif index >= 25.0 and < 29.9: print("Overweight") elif index >30.0: print("Obesity")
8th Jun 2021, 6:14 PM
Расим Багиров
Расим Багиров - avatar