Return Original PYTHON

I made a post yesterday in regards to Python but formatted it horribly.
I am making a code to solve a puzzle. It should take in the puzzle, try to solve it, then if solved, return the solved puzzle (this bit works). However if it cant solve it, then return the original puzzle completely as it was input, which isnt working.

def solve(puzzle):
        replica=deepcopy(puzzle)
        solve(puzzle)
        if complete:
                return puzzle
        else:
                return replica

I am not sure if I am using deepcopy wrong but I am getting a distorted puzzle returned. I was wondering if anybody knew of a way I could simply get the inputted puzzle returned where I currently have replica.

I believe deepcopy is a part of the copy module. So you need to import copy and then do copy.deepcopy().