jeudi 4 octobre 2018

Beginner Python 3.x loop question if - elif - else

if totalbmi <= 19:
    print('Your bmi is {}, you are underweight'.format(totalbmi))
elif totalbmi >= 20 or totalbmi <= 28:
    print('Your bmi is {} you are normal weight'.format(totalbmi))
else:
    totalbmi >= 29
    print('your bmi is {} you are overweight'.format(totalbmi))

is returning: Your bmi is 55.4016620498615 you are normal weight.

Sorry for this obviously dumb beginner question, but I am a dumb beginner and everything seems logically correct to me. If totalbmi is a number greater than 20, or less than 28 it returns "Normal weight" as it's supposed to. If totalbmi is a number less than or equal to 19 it returns "underweight" again as it's supposed to. But anything >= 29 always seems to loop back into "You are normal weight" and is not returning "You are overweight" ... as it should?

Thanks in advance for your help

Aucun commentaire:

Enregistrer un commentaire