Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 26, 2020 03:24
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/d9f66609d0952a2b7ac34a61f9cd9de9 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/d9f66609d0952a2b7ac34a61f9cd9de9 to your computer and use it in GitHub Desktop.
from copy import deepcopy
x=[1,2,[3,4]]
#deepcopying x
y=deepcopy(x)
#Modifying elements in the outer list.
#It is not reflected in the copied list.
x[0]=99
print (x)#Output:[99, 2, [3, 4]]
print (y)#Output:[1, 2, [3, 4]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment