csiro-data-school / python

Lesson webpage:
https://csiro-data-school.github.io/python
Other
3 stars 6 forks source link

Slicing lists diagram are off by 1 for negative values #81

Open Spaxe opened 4 years ago

Spaxe commented 4 years ago

The diagram for visualising slicing (https://csiro-data-school.github.io/python/04-lists/index.html) says

+---+---+---+---+---+---+---+---+
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
+---+---+---+---+---+---+---+---+
0   1   2   3   4   5   6   7   8
-8  -7  -6  -5  -4  -3  -2  -1

Where as it should be (note the offset)

+---+---+---+---+---+---+---+---+
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
+---+---+---+---+---+---+---+---+
0   1   2   3   4   5   6   7   8
    -8  -7  -6  -5  -4  -3  -2  -1