¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita0
BMI calculator bug?
I’m having trouble getting my code to output anything other than underweight. Hopefully y’all’s can help me understand what I have wrong here weight = int(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")
2 Respuestas
+ 6
Don't put your condition inside quotation marks. Currently you are checking if a string is true, and a nonempty string is always evaluated to true, that's why you always get underweight.
+ 1
Thank you been wracking my brain over this for a day im glad it was a simple fix