guessthenumber print games left

eschneider92 at comcast.net eschneider92 at comcast.net
Thu Apr 11 01:34:41 EDT 2013


On Wednesday, April 10, 2013 5:39:23 AM UTC-4, eschne... at comcast.net wrote:
> Could anyone tell me how to make the program tell me how many games are left before the first game and second game? For example, after one game of guess the number, I want it to tell me that i get one more game. P.S. I'm totally new to python (obviously), and I just added numberofgames variable in hopes of solving this problem. am I on the right track? Thanks for any assistance!
> 
> numberofgames=1
> 
> while numberofgames<4:
> 
>     numberofgames=numberofgames+2
> 
>     import random
> 
>     print ('type name')
> 
>     name=input()
> 
>     print ('guess a number between 1 and 20, ' + name)
> 
>     number=random.randint(1,20)
> 
>     guessestaken=0
> 
>     while guessestaken<5:
> 
>         guessestaken=guessestaken+1
> 
>         guess=input()
> 
>         guess=int(guess)
> 
>         if guess<number:
> 
>             print ('your guess is too low')
> 
>         if guess>number:
> 
>             print ('your guess is too high0')
> 
>         if guess==number:
> 
>             break
> 
>     if guess==number:
> 
>         print ('you win!')
> 
>     if guess!=number:
> 
>         number=str(number)
> 
>         print ('you lose. the number was ' + number)

I can't figure out how to make it count down by itself and state how many are left.



More information about the Python-list mailing list