What wrong with my code?


im trying to calculate approximate height
but i dont know why, when i run the code and answer line 5 (num2 = raw_input("What is your mother's height in centimeters?")) nothing happend. the code dont print anything. why?

name = raw_input('Hello what is your name?')
print "Hello %s, nice name!, my name is botpython and im gonna calculate your approximate height" %(name, )
sex = raw_input("Are you boy or girl?")

num1 = raw_input("What is your father's height in centimeters?")
num2 = raw_input("What is your mother's height in centimeters?")
if sex is "boy":
    print "%s, your approximate height is %s centimeters" % (name, [{num1+num2+13}/2])
elif sex is "girl":
    print '%s, your approximate height is %s centimeters' % (name, [{num1+num2-13}/2])


Try to use ( ) instead of [ ] and { }


still dont work
its dont print anything


Do you get any error message along with that code? If yes, what does it say?

Is the code okay if you write "boy"?


Simple problem. Do you know the function of an 'is' operator in Python?

You want to check that if the variable sex is equal to "boy". So wouldn't you rather do?

if sex == "boy":

Same goes for the elif. Also, you may want to average the two numbers somewhere else first, and then simply print that variable. It would seem easier to do that, wouldn't it?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.