[Tutor] My first python program!

Alan Gauld alan.gauld at blueyonder.co.uk
Wed Aug 18 09:21:11 CEST 2004


> Ok here is something I can't figure out I put a define at the top of
the
> program called   tries = 5
>
> I need to make this part of the program count down from 5 every time
they
> get a guess wrong. How do I do that?
>
> def game2():
>   a = randrange(1, 10)
>   guess = int(raw_input("Pick a number from 1 to 10, You only get 5
tries!:
> \r\n") )


>   while guess != a and tries > 0:
        tries = tries - 1

Boolean operators allow you to combine tests.
Take a look at the Raw Materials and Branching topics in my tutorial
for more about Boolean values and expressions.


HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld/tutor2/



More information about the Tutor mailing list