Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add list #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion notebooks/beginner/notebooks/lists.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,31 @@
"print('original: {}, modified: {}'.format(original, modified))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Copying a list"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"list1 = [1,2,3]\n",
"#Don't\n",
"copy1 = list1 # It will simply point the pointer of copy1 to list1 i.e. changes in copy1 appears in list1 also\n",
"copy1[2] = 6\n",
"print(list1)\n",
"\n",
"#Do - Slicing\n",
"copy2 = list1[:] #It will copy every element of list1 to copy2\n",
"copy2[1] = 5\n",
"print(list1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -310,7 +335,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.4"
"version": "3.8.8"
}
},
"nbformat": 4,
Expand Down