2

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"
3
  • 1
    Please paste the code into the question. Links go bad over time, and where would that leave SO? Commented May 16, 2014 at 17:50
  • Your condition can never be True. Why would that block ever run? Commented May 16, 2014 at 17:51
  • 1
    It needs to be an "in", not an equality to the tuple. What's being entered isn't equivalent to it... It's a member of it. Commented May 16, 2014 at 17:51

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@The10thDoctor Great, glad I could help. If my answer was helpful to you, would you mind accepting it after the grace period has passed? You can do it by clicking on the tick below the vote counts so it turns green and stays green. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.