[docs] Python.remove() function working on all list instead of one.
Julien Palard
julien at palard.fr
Wed May 22 05:38:29 EDT 2019
Hi Shayer,
Thanks for reporting!
In this case, you're having a single list, but three names to name it: The list is [1, 2, 3, 4, 5] and the list names are a, b, and c.
So when you modify a list by one of its name, you can see the modification thrue the other names. Not only for deletions:
>>> a = list(range(10))
>>> b = a
>>> a.append('foo')
>>> b
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'foo']
If you want two lists you can create two distinct lists, or use the copy method:
>>> a = list(range(10))
>>> b = a.copy()
>>> a.append(42)
>>> b
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Hope it helps!
Bests,
--
Julien Palard
https://mdk.fr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190522/ad0c959f/attachment.html>
More information about the docs
mailing list