Reputation: 125
I have tested out the following program, and there are no errors. But whenever I enter "hangman"
it won't start the new block of if
statement code named "if response_2"
. Why is it not running it?
response_2 = raw_input("What would you like to play? Hangman or Word Guess?")
if response_2 == ("Hangman", "hangman"):
print "Running Hangman..."
print "Catching Criminals..."
print "Building Gallows..."
print "Getting that one song boy from Pirate's of the Carribean"
elif response_2 == ("Word_Guess", "word_guess", "word guess", "Word Guess", "Word guess", "word Guess", "Word_guess", "word_Guess"):
print "Not completed yet"
Upvotes: 2
Views: 123
Reputation: 20351
This is because you are directly comparing to the tuple with ==
, which will always give False
as the raw_input
gives a string, not a tuple
. You need to check if any one of the responses is in the sequence. Do this with in
:
if response in ('Hangman', 'hangman'):
Likewise with the similar comparison within the elif
.
Upvotes: 7