Python 2.7: if code block not working -
i have tested out following program, , there no errors. whenever enter "hangman" won't start new block of if statement code named "if response_2". why not running it?
response_2 = raw_input("what play? hangman or word guess?") if response_2 == ("hangman", "hangman"): print "running hangman..." print "catching criminals..." print "building gallows..." print "getting 1 song boy pirate's of carribean" elif response_2 == ("word_guess", "word_guess", "word guess", "word guess", "word guess", "word guess", "word_guess", "word_guess"): print "not completed yet"
this because directly comparing tuple ==, give false raw_input gives string, not tuple. need check if 1 of responses in sequence. in:
if response in ('hangman', 'hangman'): likewise similar comparison within elif.
Comments
Post a Comment