I am trying to get the following recursive function to work. It is supposed to find the biggest list of vectors in vspace(n) such that all the vectors are at least distance d from each other. My current issue is that the variable sol does not seem to be behaving locally. For some reason when the code shifts back to earlier iterations, the variable sol does not revert back to what it was in that iteration of bestCode. Any ideas?
rlist is a function that reduced a list of vectors by removing any that are too close to x (less than distance d).
def bestCode(n, d, sol):   
    best=[]
    v = vspace(n)
    for i in range(0, len(sol)):
        v = rlist(sol[i], v, d)
    if(len(v) != 0):
        for i in range(0, len(v)):
                sol2 = sol
                sol2.append(v[i])
                sol2 = bestCode(n, d, sol2)
            if(len(sol2)>len(best)):
                best = sol2
        return best
    else:
        return sol
 
    