Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
list_copy_shallow_deep.py
#python 3.5.2 #Deep copy thislist = ["apple", "banana", "cherry"] mylist = thislist.copy() print(mylist) thislist[0]=12#only thislist gets affected print(thislist) print(mylist) print(id(thislist) is id(mylist)) #Deep copy thislist = ["apple", "banana", "cherry"] mylist = list(thislist) print(mylist) thislist[0]=12#only thislist gets affected print(thislist) print(mylist) print(id(thislist) is id(mylist)) #shallow copy thislist = ["apple", "banana", "cherry"] mylist=thislist print(mylist) thislist[0]=12#both lists get affected print(thislist) print(mylist) print(id(thislist) is id(mylist))
run
|
edit
|
history
|
help
0
PyFoodVatTip
kenken1
Find common characters between two strings
Lesson 3 HW-Final
mean
Sk
linked_lists
L4-HW final
PyMenuClass2
P