still having problems with "Nim". using python 2.6.4

Steve Holden steve at
Sun Feb 7 16:46:34 CET 2010

Jordan Uchima wrote:
> I have attached the file that the game is on. feel free to modify it to
> make it better. all suggestions are welcome. if you don't want to
> download the file then here's the code:
> my problem is that i can't get it to make the players have more than 1
> turn each, it accepts any value for playerChoice, (it is only supposed
> to accept values from 1 to 4), and "x" resets after each turn. i can get
> it to subtract playerChoice from "x", and display the result, which
> should be "x", but, then, "x" resets... by the way, i need this program
> finished by wednesday, Feb.  10, 2010. Please help me!!!
The deadline implies an even higher probability that this is homework. I
don't know whether you declared this in your earlier post, but it's
always as well to do so. You've made a substantial effort to solve the
problem though, so I don't mind trying to help. I hope you regard the
following as helpful.

You need a program structure that keeps going until the required
termination condition is reached. One such structure would be:

    while sticks_remaining > 1:

So now you only need a next_player() function that returns alternate
values on successive calls and a taketurn() function that reduces the
number of sticks according to the instructions form the given player.

Steve Holden           +1 571 484 6266   +1 800 494 3119
PyCon is coming! Atlanta, Feb 2010
Holden Web LLC       

More information about the Python-list mailing list