There is another way of copying a list that was not listed until now: adding an empty list: l2 = l + [].
I tested it with Python 3.8:
l = [1,2,3]l2 = l + []print(l,l2)l[0] = 'a'print(l,l2)It is not the best answer, but it works.
There is another way of copying a list that was not listed until now: adding an empty list: l2 = l + [].
I tested it with Python 3.8:
l = [1,2,3]l2 = l + []print(l,l2)l[0] = 'a'print(l,l2)It is not the best answer, but it works.