Skip to content
Advertisement

Tag: shallow-copy

How to properly copy a list in python

I would like to keep track of bubble sorting algorithm’s intermediate states at each iteration. I’ve tried to cache them in dictionary while loop is running, but i keep getting the same state all the time Here is my code: Here is the output: As you can see, it outputs sorted list each time. What am I missing here? Answer

Advertisement