+ 1

Bmi calculator - Hello, guys. How can i solve this problem? My code isn't matching.

bmi = float(input()/float(input())**2 if bmi <18.5 : print('Underweight.') elif bmi >=18.5 and <25 : print('Normal.') elif bmi >=25 and <30 : print('Overweight.') else : print('Obesity.')

23rd May 2022, 9:39 PM
Ruan
Ruan - avatar
9 Answers
+ 3
Not really. The test case just expects your output without any other punctuation marks. E.g "Underweight" and not "Underweight." They are different outputs
23rd May 2022, 10:48 PM
Emeh Matthew
Emeh Matthew - avatar
+ 1
#try this weight = float(input()) height = float(input()) bmi = weight / height**2 if bmi < 18.5: print("Underweight") elif 18.5 <= bmi < 25: print("Normal") elif 25 < bmi < 30: print("Overweight") else: print("Obesity")
23rd May 2022, 10:10 PM
Emeh Matthew
Emeh Matthew - avatar
+ 1
Emeh Matthew Man, i want to thank you. I stopped this course months ago because i couldn't solve this and now tou save me. đŸ±
23rd May 2022, 10:17 PM
Ruan
Ruan - avatar
+ 1
Helping each other is how we learn better đŸ€
23rd May 2022, 10:23 PM
Emeh Matthew
Emeh Matthew - avatar
+ 1
I think we applied the same logic. You just made some errors like: - Including a period (.) in your print statements - Your elif conditions were wrongly written. bmi >= 18.5 and < 25 is invalid syntax. Instead say bmi >= 18.5 and bmi < 25 or more compactly 18.5 <= bmi < 25. Asides these, your logic is correct
23rd May 2022, 10:31 PM
Emeh Matthew
Emeh Matthew - avatar
0
Changes bmi = float(input()) / float(input())**2 elif 18.5 <= bmi < 25: print("Normal") elif 25 <= bmi < 30:print("Overweight")
23rd May 2022, 9:46 PM
Emeh Matthew
Emeh Matthew - avatar
0
Emeh Matthew i get invalid syntax here
23rd May 2022, 9:50 PM
Ruan
Ruan - avatar
0
Emeh Matthew I agree. How you solve this?
23rd May 2022, 10:24 PM
Ruan
Ruan - avatar
0
Emeh Matthew So this dot (.) refers to somenthing? Lol. It's more hard than i tought. Thanks, man.
23rd May 2022, 10:41 PM
Ruan
Ruan - avatar