Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > a question about lists

Reply
Thread Tools

a question about lists

 
 
pythonbeginner pythonbeginner is offline
Junior Member
Join Date: Sep 2012
Posts: 1
 
      09-01-2012
I am new to Python. Here is a question I have about lists:
It is said that lists are mutable and tuples are immutable. But when I write the following:

L1 = [1, 2, 3]
L2 = (L1, L1)
L1[1] = 5
print L2

the result is
([1, 5, 3], [1, 5, 3])

instead of
([1, 2, 3], [1, 2, 3])

But L2 is a tuple and tuples are immutable. Why is it that when I change the value of L1, the value of L2 is also changed?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
lists of lists Jon Slaughter C++ 4 12-13-2004 06:28 PM
Lists of Lists VWWall Computer Information 2 10-21-2004 01:15 AM
Counter for items in lists in lists? Charlotte Henkle Python 8 09-26-2004 04:22 AM
Sorting lists of lists... JustSomeGuy C++ 0 06-17-2004 05:44 PM



Advertisments