I'm trying to write a function that takes a list as an input and returns a modified version of that list such that the function does not change the input list. The input variable T is a list of lists. I have tried
def function(T):
Tree = copy.copy(T)
Do stuff with Tree
return Tree
only to discover that T
has been changed by the function. I have also tried Tree = T[:]
but that also doesn't work. Any suggestions?