0
    >>> l1 = [1,2,3]
    >>> l2 = l1
    >>> l2
    [1, 2, 3]
    >>> l1.append(4)
    >>> l1
    [1, 2, 3, 4]
    >>> l2
    [1, 2, 3, 4]

In above l2 list updated automatically.

Case 2:

>>> a=10
>>> b=a
>>> a = a+5
>>> a
15
>>> b
10

but here b never changed. What is the difference between these list and other data structure properties.

Ravi Kumar
  • 1,769
  • 2
  • 21
  • 31
  • What you meant by your last example was `a += 5`. – jamylak Feb 11 '15 at 11:08
  • @jamylak in the above list automatically updated, when i changed l1, l2 automatically changed, l1, l2 are same list, but in case2 a & b are also same by changing a, b not changed. – Ravi Kumar May 05 '15 at 05:04
  • I wasn't referring to that. In Case 2, you meant to say `a += 5` because you wanted to show that `b` doens't chang. But you actually just did `a + 5` which doesn't even change `a` – jamylak May 05 '15 at 15:13

0 Answers0