[Tutor] Minesweeper implementing 20%, weird problem with matrixes
albertito_g at hotmail.com
Thu Jul 14 15:36:49 CEST 2005
I didn't notice that :P
Thanks to Alan, I learn something new with the use of List Comprehension and
thanks to Danny for the docs, they really helped a lot to understand the
I think I can say that Minesweeper implementing 23% with this problem solved
Thanks a lot
>From: "Alan G" <alan.gauld at freenet.co.uk>
>To: "Alberto Troiano" <albertito_g at hotmail.com>, <tutor at python.org>
>Subject: Re: [Tutor] Minesweeper implementing 20%,weird problem with
>Date: Thu, 14 Jul 2005 01:12:18 +0100
> > I initialize them by putting None along all the fields
>Actually you don't.
> def initialize(self):
>3 empty lists, so far so good.
> for i in range(self.fil):
> for j in range(self.col):
>a new list filled with None
>THat same list inserted into all three lists, so they all point
>at the same internal list of Nones. So when you change one,
>you change all.
>Try using aux[:] instead to take a copy of aux...
>You could also use list comprehension instead of the loop/append:
>aux = [None for i in range(self.col)]
>Tutor maillist - Tutor at python.org
More information about the Tutor