If I have a list like
a=[1,4,2]
and I create a new list in the following way
b=a
I found out that any modification to b
would be applied to a
as well:
b.sort()
print b
print a
b.pop(-1)
print b
print a
How can I create a copy of a list which I can modify at pleasure without affecting the original?
So, in my example, every time I print a
I want to obtain the initial output [1,4,2]
, no matter what I do to b
.