Question: Deepish Copy You saw in lecture the difference between a shallow copy and a deep copy. Write a function deepishCopy ( xx ) that takes

Deepish Copy
You saw in lecture the difference between a shallow copy and a deep copy.
Write a function deepishCopy(xx) that takes a list of lists xx and returns a deepish copy of that list. What we mean is that your function should create a new list and add shallow copies of everything to that list. So, given
xx =[[1,2,3],[4,5,6],5] yy =[[[1,3],[3,4]],[4,6],23]
deepishCopy(xx) will completely copy everything in xx.
deepishCopy(yy) will completely copy [4,6] and 23, but the [[1,3],[3,4]] will be a shallow copy.
(For the more technically inclined, this means you do not need recursion.)
Running it, we could get this behavior:
>>> xx2= deepishCopy(xx)>>> xx[1][1]=999>>> xx,xx2[[1,2,3],[4,999,6],5],[[1,2,3],[4,5,6],5]>>> yy = deepishCopy(yy)>>> yy[0][0][1]=999>>> yy[1][0]=888>>> yy,yy2[[[1,999],[3,4]],[888,6],23],[[[1,999],[3,4]],[4,6],23]
Do not use the built-in deepcopy to do this. It will do too much.
Hint: the code type(x)== list will be useful to you.
The setup code gives the following variables:
Your code snippet should define the following variables:
NameTypedeepishCopyfunction
user_code.py
1
2
def deepishCopy(xx):
Restore original file
Save onlySave & Grade Unlimited attempts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!