basic 2 player wordgame

Mel mwilson at the-wire.com
Tue Sep 21 08:39:00 EDT 2010


Baba wrote:
> I am working on a simple wordgame exercise: 2 players form a word by
> alternating turns saying a letter, which is added on to the end of the
> word fragment.
> 
> I am familiar with loops, iterations etc but i need a hint as to how
> to approach alternating turns when writing this code?

One way (not tested):

thisplayer = Player()
otherplayer = Player()
while not_won:
    thisplayer.take_turn()
    thisplayer, otherplayer = otherplayer, thisplayer



	Mel.




More information about the Python-list mailing list