0

Help fix my Python beginner lesson: bmi calculator

height = int(input()) weight = int(input()) bmi = int(input(weight/(height**2)) underweight = (bmi<18.5) normal = (bmi>=18.5) and (bmi<25) overweight = (bmi>=25) and (bmi<30) obesity = (bmi>=30) if bmi = underweight: print("Underweight") else: if bmi = normal: print("normal") else: if bmi = overweight: print("overweight") else: if bmi = obesity: print("obesity") else: print("none")

30th Sep 2021, 10:51 PM
slick
slick - avatar
3 Answers
+ 4
1. You shouldnt convert your input to int on line 1 and 2. It should be converted to float. As height is a float rather than int. 2. On line 3, you should not convert your bmi to int after calculating it... Also invalid use of input() on the same string. 3. Use elif instead of all these nested if else statements. 4. You have messeed up with TABS on lines 10-19 5. Your output should start with capitals otherwise your program wont pass the tests 6. You used comparison between bmi and a bool variables, which obviously wont work. Instead you could use your bool variables as follows: e.g. "if underweight:" Here is the fixed version of your code: https://code.sololearn.com/cldxnF7gjOQR/?ref=app
30th Sep 2021, 11:34 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
Input weight first, then height. Convert weight to float instead of int.
1st Oct 2021, 3:34 AM
Brian
Brian - avatar
+ 1
thank you!
1st Oct 2021, 3:35 PM
slick
slick - avatar