Python swapping lists

Viewed 18130

In python, when I assign a list to another, like:

a = [1,2,3]
b = a

Now b and a point to the same list. Now considering two lists,

a = [1,2,3]
b = [4,5,6]
a,b = b,a

Now how is it that they are swapped like any other data type and does not end up both pointing to the same list?

3 Answers
Related