jerry-git / learn-python3

Jupyter notebooks for teaching/learning Python 3
MIT License
6.43k stars 1.77k forks source link

added list.copy() in lists.ipynb #8

Closed manoharganta256 closed 5 years ago

manoharganta256 commented 6 years ago

Added copy() method in lists.ipynb along with a simple example.

jerry-git commented 5 years ago

Thanks for the PR!

I feel that this should be under Lists are mutable section. Actually, I think list() is doing exactly the same job and I feel that it's more Pythonic (of course just my personal opinion). Thus, I would mention that there is also copy method but I wouldn't necessarily devote a new section for it.

Maybe you could mention it as an alternative under Lists are mutable. For example:

modified = list(original)  # Note list()
# Alternatively, you can use copy
# modified = original.copy()