Oct-15-2017, 05:29 PM
(This post was last modified: Oct-15-2017, 05:29 PM by nexusfactor.)
I was reading Python Crash Course (excellent book btw!), in it, the author copies a list by slicing it, and demonstrates that the new list is independent, any change in the new list, will not be reflected in the old one. On SO, the accepted answer states the prefer method is:
because it's more readable.
On Slicing:
I prefer using the [:], it's simple and understandable to me. Any reason why I should stop using it?
new_list = list(old_list)
because it's more readable.
On Slicing:
Quote:it is a weird syntax and it does not make sense to use it ever. ;)
I prefer using the [:], it's simple and understandable to me. Any reason why I should stop using it?