P
Panard
Hi!
Can anyone explain this to me :
$ cat test.py
l = [ 1, 2, 3 ]
d = { 'list' : l }
for x in l :
print "rm", x
d[ 'list' ].remove( x )
print "l =", l
print d
$ python test.py
rm 1
l = [2, 3]
rm 3
l = [2]
{'list': [2]}
Why 2 isn't removed ? and why l is changing during the loop ??
Am I missing something ?
My python is 2.3.4
Thanks
Can anyone explain this to me :
$ cat test.py
l = [ 1, 2, 3 ]
d = { 'list' : l }
for x in l :
print "rm", x
d[ 'list' ].remove( x )
print "l =", l
print d
$ python test.py
rm 1
l = [2, 3]
rm 3
l = [2]
{'list': [2]}
Why 2 isn't removed ? and why l is changing during the loop ??
Am I missing something ?
My python is 2.3.4
Thanks