How to fix a Python elif? -
okay have below code performing don't want do. if run program ask "how you?" (obviously), when give answer question applies elif statement, still if statement response. why this?
talk = raw_input("how you?") if "good" or "fine" in talk: print "glad here it..." elif "bad" or "sad" or "terrible" in talk: print "i'm sorry hear that!"
the problem or
operator not want here. you're saying if value of "good" true or "fine" in talk
. value of "good" true, since it's non-empty string, why branch gets executed.
Comments
Post a Comment