Newb ??

Chad Everett everettcc at hotmail.com
Wed Nov 9 21:41:46 EST 2005


Hey guys,

Thanks for your help.  I am glad to know there is a community out there 
willing to put the effort out to help us newbies.  I will work on it.  Some 
of the suggestions are things that I have not covered yet but I am sure I 
will figure it out.

Thanks again.

I am sure I will be back with more questions before too long.

Chad


"Chad Everett" <everettcc at hotmail.com> wrote in message 
news:mzdcf.470$rN2.320 at bignews2.bellsouth.net...
> Hi all,  I am new to the group.  Trying to learn Python programming on my 
> own.  I am working through Michael Dawson's Book Python Programming for 
> the absolute beginner.
>
> I am tring to write a program that is a number guessing game.  I want to 
> be able to give the user 5 tries to guess the number before the program 
> ends.
>
> I get the result that I want when the user misses after the 5th try.  But 
> it does not go down to my closing statement to end.  Rather is askes for 
> another guess.
>
> I appreciate any help you can give.  If  this is not the correct group for 
> these types of questions, I apologize and hope that you can direct me to 
> another NG.
>
> Thanks,
> Chad
>
> import random
>
> print "\tWelcome to 'Guess my Number'!"
> print "\nI'm Thinking of a Number between 1 and 100."
> print "\nTry to Guess it in as few attempts as possible.\n"
>
> #Set the initial values
> the_number = random.randrange(100) + 1
> guess = int(raw_input("Take a guess:"))
> tries = 1
>
> #Guessing Loop
>
> while (guess != the_number):
>    if (guess >the_number):
>        print "Lower..."
>    else:
>        print "Higher..."
>    guess = int(raw_input("Take another Guess:"))
>    tries +=1
>    if tries == 5:
> print "Sorry you lose."
> print "The Correct Number was ", the_number
>
>
> print "You guess correctly!!"
> print "The number was:", the_number
> print "You got it correct in", tries, "tries"
>
> raw_input("Press Enter to exit the program")
> 





More information about the Python-list mailing list