On Apr 6, 5:16 pm, Helmut Jarausch <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I must be blind but I don't see what's going wrong
> with
>
> G=[[]]*2
>
> G[0].append('A')
> G[1].append('B')
> print G[0]
>
> gives
>
> ['A', 'B']
>
> as well as
> print G[1]
>
> I was expecting
> ['A']
> and
> ['B']
> respectively.
>
> Many thanks for enlightening me,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany

This is in the top two FAQ, here is the relevant section:

http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list

HTH

--
Arnaud

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to