append to a sublist - please help

Helmut Jarausch jarausch at skynet.be
Sun Apr 6 12:16:02 EDT 2008


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



More information about the Python-list mailing list