Here is part of my code:
students = 0
weight = 0
height = 0
while students < 5:
name = input("Please enter the name. ")
students = students + 1
while weight == 0:
try:
weight = float(input("Please enter the weight in kgs "))
if weight <= 0:
print ("Please enter a number greater than zero ")
weight = 0
continue
except ValueError:
print ("No number found, please enter a number greater than zero ")
weight = 0
continue
while height == 0:
try:
height = float(input("Please enter the height in metres "))
if height <= 0:
print ("Please enter a number greater than zero ")
height = 0
continue
except ValueError:
print ("No number found, please enter a number greater than zero ")
height = 0
continue
BMI = (weight/(height*height))
print (name, "has the BMI of", "%.2f" %BMI)
if BMI < 18.5:
print ("The student is underweight.")
elif 18.5 <= BMI <= 27:
print ("The student is a healthy weight.")
elif BMI > 27:
print ("The student is overweight.")
weight = 0
height = 0
However, when the BMI is 18.5 it says that the student is underweight and when the BMI is 27 it says the student is overweight, when both should actually be a healthy weight? e.g. 53.456 for weight and 1.7m for height shows up as underweight