I'm having a problem with if statement that's checking if input is correct. It when I input M or F it prints out "Wrong input" and I don't understand it very clearly.
def check(aw,iw):
if abs(aw-iw)<5 :
print "Your weight is normal."
elif abs(aw-iw)>5 and abs(aw-iw)<15 :
print "Your weight is about normal."
else:
print "Your weight is not normal."
return
print "Enter your gender (M/F)"
gender=raw_input()
gender=int(gender)
if gender!='M' or gender!='F':
print "Wrong input."
else:
if gender=='M':
w=raw_input("Enter your weight (kg) :")
h=raw_input("Enter your height (cm) :")
idw=110-h
check(w,idw)
else:
w = raw_input("Enter your weight (kg) :")
h = raw_input("Enter your height (cm) :")
idw = 110 - h
check(w, idw)
Aucun commentaire:
Enregistrer un commentaire