x = y
j_lockley at hotmail.com
Tue Feb 6 23:23:44 CET 2001
[[1, 2, 3], 'me']
[[1, 2, 3], [4, 5, 6]]
"Bernie" <bernie at pacific.net.hk> wrote in message
news:3A807382.298371E0 at pacific.net.hk...
> "José Luis Gallego" wrote:
> > Hi all,
> > I want to create a list x from a list y:
> > y = [[1,2,3],[4,5,6]]
> > x = y
> > How do I change individual elements of x without changing y?
> I think you need the copy module.
> import copy
> y = [[1,2,3],[4,5,6]]
> x = copy.copy(y)
> This will do for a shadow copy. See documentation for the copy module
> in Python
> Library Reference for furthur details
> > Thanks in advance,
> > Jose Luis
More information about the Python-list