Hi,
I am trying to assign the list elements(l1) to another list (l2).When I am trying to remove the element from l2,it is removing the element from l1.
Is there any method available to copy the list elements?So that I can avoid deleting the elements.
O/P :
I need l1 = [1,2,3,4] and l2 = [1, 2, 4]
Thanks
PSB
I am trying to assign the list elements(l1) to another list (l2).When I am trying to remove the element from l2,it is removing the element from l1.
Is there any method available to copy the list elements?So that I can avoid deleting the elements.
Code:
Sample >>> l1 = [1,2,3,4] >>> l2 = l1 >>> l2.remove(3) >>> l1 [1, 2, 4] >>> l2 [1, 2, 4] >>>
I need l1 = [1,2,3,4] and l2 = [1, 2, 4]
Thanks
PSB
Comment