Add illustration for visual intuition of indexing and slicing#1118
Conversation
This illustration has been used to help beginners understand why the last digit of a slice doesn't imply including another element. The intuition makes a distinction between indexing, the number of the position, and slicing, the number of the gap between elements. For step based slices, the alternative intuition is to create rows with the values and keeping only the first row.
Thank you!Thank you for your pull request 😃 🤖 This automated message can help you check the rendered files in your submission for clarity. If you have any questions, please feel free to open an issue in {sandpaper}. If you have files that automatically render output (e.g. R Markdown), then you should check for the following:
Rendered Changes🔍 Inspect the changes: https://github.com/swcarpentry/python-novice-inflammation/compare/md-outputs..md-outputs-PR-1118 The following changes were observed in the rendered markdown documents: What does this mean?If you have source files that require output and figures to be generated (e.g. R Markdown), then it is important to make sure the generated figures and output are reproducible. This output provides a way for you to inspect the output in a diff-friendly manner so that it's easy to see the changes that occur due to new software versions or randomisation. ⏱️ Updated at 2026-06-22 19:37:35 +0000 |
|
Hi @unode, Thank you for taking the time to add the illustrations. |
|
The illustration is an SVG with transparent background and has only been tested on light backgrounds. Dark themes have not been tested. I wasn't aware that this is now part of the lesson pipeline. It should be possible to extend the SVG to include support for dark themes but perhaps the easiest would be to force a light background rather than having it see-through. |
|
It is not part of the pipeline for dark and light theme for any of the lesson I think. It is just that browser on a dark mode desktop device. This is just me opening the image independently in another tab on the browser and all the transparent text boxes become dark. I think all the text boxes should have solid color background to avoid this native browser background. |
|
I can't replicate your experiences with dark mode settings.
The raw SVG "page" also looks fine to me regardless of which settings I change. @noatgnu could there be something else causing the visual artifacts you showed in your screenshot above? I'm on Firefox, Linux, and to me it looks like the screenshot above. Dark mode takes the soul out of it and makes it suffer from contrast issues but is still visually consistent. |
|
I see now here that the 2 in the first line has very little contrast. I'll update the image and darken the yellow slightly. |
|
@unode This is so much better! I would merge this. Thank You for your contribution! |
Auto-generated via `{sandpaper}`
Source : 47a5c40
Branch : md-outputs
Author : GitHub Actions <actions@github.com>
Time : 2026-06-29 11:21:45 +0000
Message : markdown source builds
Auto-generated via `{sandpaper}`
Source : 2b3613a
Branch : main
Author : Olushola Ogunkelu <sogunkelu@gmail.com>
Time : 2026-06-29 11:19:50 +0000
Message : Merge pull request #1118 from unode/visual-index-vs-slice
Add illustration for visual intuition of indexing and slicing
Auto-generated via `{sandpaper}`
Source : 47a5c40
Branch : md-outputs
Author : GitHub Actions <actions@github.com>
Time : 2026-06-29 11:21:45 +0000
Message : markdown source builds
Auto-generated via `{sandpaper}`
Source : 2b3613a
Branch : main
Author : Olushola Ogunkelu <sogunkelu@gmail.com>
Time : 2026-06-29 11:19:50 +0000
Message : Merge pull request #1118 from unode/visual-index-vs-slice
Add illustration for visual intuition of indexing and slicing
Auto-generated via `{sandpaper}`
Source : 47a5c40
Branch : md-outputs
Author : GitHub Actions <actions@github.com>
Time : 2026-06-29 11:21:45 +0000
Message : markdown source builds
Auto-generated via `{sandpaper}`
Source : 2b3613a
Branch : main
Author : Olushola Ogunkelu <sogunkelu@gmail.com>
Time : 2026-06-29 11:19:50 +0000
Message : Merge pull request #1118 from unode/visual-index-vs-slice
Add illustration for visual intuition of indexing and slicing
Auto-generated via `{sandpaper}`
Source : 2b3613a
Branch : dev-update-for-comp-bio-training
Author : Olushola Ogunkelu <sogunkelu@gmail.com>
Time : 2026-06-29 11:19:50 +0000
Message : Merge pull request swcarpentry#1118 from unode/visual-index-vs-slice
Add illustration for visual intuition of indexing and slicing
Auto-generated via `{sandpaper}`
Source : c197be1
Branch : md-outputs
Author : GitHub Actions <actions@github.com>
Time : 2026-07-10 13:20:54 +0000
Message : markdown source builds
Auto-generated via `{sandpaper}`
Source : 2b3613a
Branch : dev-update-for-comp-bio-training
Author : Olushola Ogunkelu <sogunkelu@gmail.com>
Time : 2026-06-29 11:19:50 +0000
Message : Merge pull request swcarpentry#1118 from unode/visual-index-vs-slice
Add illustration for visual intuition of indexing and slicing




This illustration has been used to help beginners understand why the last digit of a slice doesn't imply including another element.
The intuition makes a distinction between indexing, the number of the position, and slicing, the number of the gap between elements.
For step based slices, the alternative intuition is to create rows with the values and keeping only the first row.
@tobyhodges