Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SciProg2024
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pclark3
SciProg2024
Commits
19adf9ca
"src/ac/ed/git@git.ecdf.ed.ac.uk:lul/plumv2.git" did not exist on "0b0a9ac67ec33e55588a43a0cd1709b2b7ec0d26"
Commit
19adf9ca
authored
1 year ago
by
cprutean
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
4def0f96
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CodeExamples/ExtractSublist.ipynb
+63
-0
63 additions, 0 deletions
CodeExamples/ExtractSublist.ipynb
with
63 additions
and
0 deletions
CodeExamples/ExtractSublist.ipynb
0 → 100644
+
63
−
0
View file @
19adf9ca
{
"cells": [
{
"cell_type": "markdown",
"id": "001d5e42",
"metadata": {},
"source": [
"# Extract Sublist"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4dca2369",
"metadata": {},
"outputs": [],
"source": [
"\"\"\"\n",
" Extract a sublist and add list together\n",
"\"\"\"\n",
"\n",
"def main():\n",
"\n",
" # Make two lists\n",
" a_list = [1,2,3,4,5,6,7,8]\n",
" b_list = [9,10,11,12,13]\n",
"\n",
" # Make a third list being a_list + elements 3,4,5 of b_list\n",
" c_list = a_list + b_list[3:6]\n",
" print(\"The c_list is : \" + str(c_list) + \" of length \" + str(len(c_list)))\n",
"\n",
" # Make a fourth list being elements 4:end of a + 0,1,2 of list b\n",
" d_list = a_list[4:] + b_list[:3]\n",
" print(\"The d_list is : \" + str(d_list) + \" of length \" + str(len(d_list)))\n",
"\n",
"\n",
"\n",
"main()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:001d5e42 tags:
# Extract Sublist
%% Cell type:code id:4dca2369 tags:
```
python
"""
Extract a sublist and add list together
"""
def
main
():
# Make two lists
a_list
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
b_list
=
[
9
,
10
,
11
,
12
,
13
]
# Make a third list being a_list + elements 3,4,5 of b_list
c_list
=
a_list
+
b_list
[
3
:
6
]
print
(
"
The c_list is :
"
+
str
(
c_list
)
+
"
of length
"
+
str
(
len
(
c_list
)))
# Make a fourth list being elements 4:end of a + 0,1,2 of list b
d_list
=
a_list
[
4
:]
+
b_list
[:
3
]
print
(
"
The d_list is :
"
+
str
(
d_list
)
+
"
of length
"
+
str
(
len
(
d_list
)))
main
()
```
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment