Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active July 26, 2020 02:44
Show Gist options
  • Save IndhumathyChelliah/e8e705280ea041a827a7b2cbff0b716a to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/e8e705280ea041a827a7b2cbff0b716a to your computer and use it in GitHub Desktop.
from copy import copy
x=[1,2,[3,4]]
#Copying x
y=copy(x)
#Modifying elements in the outer list.
#Changes are 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