Hope you are doing well

When you use deepcopy , it constructs a new compound object and then, recursively, inserts copies into it of the objects found in the original. In short, you will have two different blocks containing same elements.Hence, append on one list will not affect other. Kindly check below example:

import os
import copy

a = [1,2,3,4]

b = [100,200,300,400]

print ("elements in a", a)

print ("elements in b", b)


print ("new elements in a", a)

print ("elemenst in b", b)

print ("Assingning a deepcopy will create complete new block with the same elements ")

a = copy.deepcopy(b)

print ("elements in a", a)

print ("elements in b", b)


print ("new elements after append",a)

print ("let's check b", b)

print ("lets do some append on b")


print ("elements in a", a)
print ("elements in b", b)


Hope this resolves your query

In case of any further issue,feel free to revert.

Kindly give your valuable feedback by clicking on any one of the smiley's below.

Sumit Anand
edureka! Solution Team
Website - www.edureka.co
Edureka claims 1st position at Deloitte's Technology Fast 50 India 2014