Python list names are actually pointers or references to a memory area, so a copy of a list obtained by a simple assignment is basically only another name for it. This is means that altering the copy will also change the original, which is not what you may expect. While this is convenient for efficiency reasons, if you want to edit your copy you will normally want it to be independent of the original. The slicing operator comes to the rescue here, as it allows you to create an actual, independent copy of the list, which keeps its own independent catalogue of all the elements. For more information, see the notebooks below (notebooks will open on Google Colab - no installation required)
Embedded video, part of the following courses:
Computer Programming at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/3xjmpf94
Coding for Scientists at Queen Mary, University of London
Jupyter notebook: https://tinyurl.com/yedumefr
Watch video How to copy Python lists: avoid a common pitfall online without registration, duration hours minute second in high quality. This video was added by user PatchyPython 09 September 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 74 once and liked it 0 people.