Lists into lists

Jeff Cohen jaif at mindspring.com
Mon Aug 20 16:34:23 CEST 2001


I'm just learning python, so sorry if this is obvious but I didn't see it in
the book or a few tutorials I found.

I want to insert a copy of a list into a list like so:

>>x=[1,2,3]
>>y=[4,5,6]
>> Magic step goes here
>>x
[[4,5,6],1,2,3]

Now, I did this with

>>x.insert(0,y)

However, when I manipulate y, I end up changing x as well.

With

>>x[:0]=y
>>x
[4,5,6,1,2,3]

Which isn't exactly it either.

Any help there?





More information about the Python-list mailing list