Search code examples
pythonraw-input

raw_input in python, output wrong


I am a freshman in python, and faced a problem of raw_input. see bellow

Welcome to the game, Hangman!
I am thinking of a word that is 1 letters long.
-------------
you have 8 guesses left.
Available letters: abcdefghijklmnopqrstuvwxyz
please give a guess letter: c
Good guess: c
-------------
Congratulations, you won!
None

*** ERROR: Failing test.
Expected line: Please guess a letter: c
Your code generated: please give a guess letter: c *** 

--------------------

this is the output, and my code to use the raw_input is

    guess = raw_input("please give a guess letter: ")

the right output is,

Welcome to the game Hangman!
I am thinking of a word that is 1 letters long
-----------
You have 8 guesses left
Available Letters: abcdefghijklmnopqrstuvwxyz
Please guess a letter: c
Good guess: c
-----------
Congratulations, you won!
None

the difference is about the raw_input, could you explain what happened?


Solution

  • The problem is the test script is expecting specific output of Please guess a letter:, your code has please give a guess letter:

    If you change your raw_input prompt to match the text, the test will pass.