a question about lists

Joined
Sep 1, 2012
Messages
1
Reaction score
0
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top