[Tutor] Game of python, help please.

Dave Angel d at davea.name
Tue Apr 10 04:56:58 CEST 2012

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.



More information about the Tutor mailing list