I\'m currently attempting Reddit\'s /r/dailyprogrammer challenge.
The idea is to find a solution to an ASCII maze. Unfortunately the recursion is worki
newMaze = maze
doesn't copy the list, it just creates another name pointing to the same object. To copy, you should import copy
at the top of your program, then do newMaze = copy.deepcopy(maze)
. (You need a deep copy because maze
is a list of lists, so you need to copy not only the outer list, but all the lists inside it too.)
In Python, assignment to a plain name (like blah = ...
) never copies anything. If you want a copy, you must make one explicitly. The way to do that depends on what you're copying.