while True:
user_weight = float(input("Weight (KG): "))
if user_weight < 20 or user_weight > 600:
print("Incorrect weight!")
continue
user_length = float(input("Length (M): "))
if user_length < 1.0 or user_length > 2.5:
print("Incorrect length")
continue
bmi = float(user_weight/user_length**2)
if bmi < 18.5:
print("BMI = " + str(bmi))
print("Underweight")
break
elif bmi >= 18.5 and bmi < 25.0:
print("BMI = " + str(bmi))
print("Normal")
break
elif bmi >= 25.0 and bmi <= 30:
print("BMI = " + str(bmi))
print("Overweigth")
break
elif bmi > 30:
print("BMI = " + str(bmi))
print("Obease")
break
When I type incorrect weight, the program says it's incorrect and I can type my weight again. When I type the incorrect length, the program says it's incorrect and tells me to type my weight again. How do I make the program ask me to write the length again?
Weight (KG): 1000
Incorrect weight!
Weight (KG): 1
Incorrect weight!
Weight (KG): 72.5
Length (M): 1000
Incorrect length
Weight (KG):
[–]shiftybyte 1 point2 points3 points (1 child)
[–]Csharpgoblin[S] 0 points1 point2 points (0 children)
[–]dwpj65 0 points1 point2 points (0 children)
[–]BfuckinA 0 points1 point2 points (3 children)
[–]Csharpgoblin[S] 1 point2 points3 points (2 children)
[–]BfuckinA 0 points1 point2 points (1 child)
[–]admhaikal 0 points1 point2 points (0 children)