Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 26, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/c0586f2892b76b3f1fbcf9997e40feda to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/c0586f2892b76b3f1fbcf9997e40feda to your computer and use it in GitHub Desktop.
from copy import deepcopy
x=[1,2,[3,4]]
#deepcopying x
y=deepcopy(x)
#Both contain same list elements
print (x)#Output:[1, 2, [3, 4]]
print (y)#Output:[1, 2, [3, 4]]
#Both are different list objects.Their id (memory location) is different.
print (id(x))#Output:40211720
print (id(y))#Output:40343976
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment