[Tutor] Game of python, help please.

bob gailer bgailer at gmail.com
Tue Apr 10 16:44:08 CEST 2012

On 4/9/2012 10:56 PM, Dave Angel wrote:
> On 04/09/2012 10:33 PM, bob gailer wrote:
>> On 4/9/2012 2:26 AM, leo degon wrote:
>>> Hello all, Im trying to learn python and programming in my free time,
>>> and I'm trying to do a little personal project to trying and gain
>>> some skills. Im trying to do version of John conways game of life. I
>>> have a working version of the game. Written for 3.2.2 on a mac to be
>>> accessed through terminal.
>> <SNIP>
>> These nested loops
>>> for i in range(X):
>>>      SPACE.append([])
>>>      for j in range(Y):
>>>          SPACE[i].append([0])
>> can be replaced with:
>> space = [0]*y]*x
> not counting the typo, that's the trap I was warning about.  If he does
> NOT replace the individual cells with zeroes and ones, this is wrong.
> You pointed that out.  But it's also wrong for the rows, as you only
> have one row here, duplicated x times.
OOPS - what comes of trying to be creative while tired. Sorry and thanks 
for pointing out my error.

Bob Gailer
Chapel Hill NC

More information about the Tutor mailing list