[Tutor] Help with "Guess the number" script

Scott W Dunning swdunning at cox.net
Sun Mar 2 01:43:57 CET 2014


On Mar 1, 2014, at 12:47 AM, Ben Finney <ben+python at benfinney.id.au> wrote:

> You've bound the name ‘current_guess’ to the user's input, but then do
> nothing with it for the rest of the function; it will be discarded
> without being used.
Hmm, I’m not quite sure I understand.  I got somewhat confused because the directions were changed a little and current_guess was removed from the get_guess function.  Is this more like what I should be doing?

def get_guess(guess_number):
	raw_input(“Please enter a guess”)
	guess_number = int(guess_number)
	return (guess_number)
get_guess(1)

> 
> Then, you use the parameter ‘guess_number’, create a new integer from
> it, and return that integer. I think you've used the wrong name for the
> ‘int()’ parameter.
Well, since there are no loops allowed I’m guessing get_guess will be called 9 times.  I believe guess_number is the number of tries the user has used.
So;
(1) Please enter a guess: 
(2) Please enter a guess:



More information about the Tutor mailing list