[Tutor] Why doesn't it choose a new number each time?

Alan Gauld alan.gauld at btinternet.com
Wed Feb 14 09:48:34 CET 2007

"Rikard Bosnjakovic" <rikard.bosnjakovic at gmail.com> wrote
> On 2/14/07, Nathan Pinno <falcon3166 at hotmail.com> wrote:
>>  I wrote a rock, paper, scissors game and every time you play 
>> without
>> exiting, it chooses the same number. How can I fix this problem? 
>> The
>> relative code is below:
> [...]
>>         compchoice = choice(range(3))
> [...]
>>>> range(3)
> [0, 1, 2]
> You either have to change your if-case ranges from 1-3 to 0-2, or
> simply add one to the "compchoice" variable.

I don't think that's a problem. The fact that the computers numbers
don't correspond with the users numbers shouldn't matter provided
the 'if' tests align with the choice result, which they do.

I've now tried running it on my PC and get:

>>> Welcome to Rock, Paper, or Scissors!
by Nathan Pinno
© 2007. All rights reserved.

AI chose scissors.
You chose rock. You win!
AI chose rock.
You chose paper. You win!
AI chose scissors.
You chose scissors. Tie game.
Which all looks fine.

What exactly was the problem you found Nathan?

Alan G. 

More information about the Tutor mailing list