1 Your sequence
variable name
sequence source
Apply ▸
"COMP1021"
xx (slide)
my_list (slide)
[[1, 2], [3, 4], [5, 6]]
2×2×2 cube
6D nest
[10, 20, 30, 40, 50, 60]
("a", "b", "c",
"d", "e")
range(8)
Leave a box empty to keep the original example — the grey placeholder shows what
will be used.
2 The access
Read ·
a[…]
Assign ·
xx[…] = …
expression — a[ … ]
Apply ▸
Pending — press Apply ▸ / Run ▸ (or Enter) to
update the code and the picture.
[2]
[-1]
[10]
[1:2]
[1:]
[::2]
[::-2]
[::-1]
[1:6:2]
[1023:1023]
[-1023:1023]
[1023:-1023]
[1023:-1023:-1]
[::0]
Click a chip or type your own — e.g. a[1:len(a)-1]. Negative numbers
count from the end. An empty box keeps the original example. Nothing runs until you press Apply ▸ /
Run ▸ .
[1][0:2]
[1:3][1]
[1][0][1]
[0][0][0][0][0][0]
[1][:500:1]
Chained subscripts walk into nested lists — try them with the cube / 6D nest
sequences (up to 6 dimensions).
xx = ["COMP", 1023]
xx[0] = ["COMP", 1023]
xx[1:3] = ["COMP", 1023]
xx[1:2] = ["COMP", 1023]
xx[1:1] = ["COMP", 1023]
xx[1:1] = []
xx[:] =
[]
xx[::2] = ["COMP", 1023]
xx[::3] = ["COMP", 1023]
xx[::4] = ["COMP", 1023]
xx[::-2] = ["COMP", 1023]
xx[::-1] = []
xx[::] = "COMP 1023"
my_list[2][-2:] = ["not a"]
Slide exercise: pick a case, then press Run ▸ to check the answer.
Empty boxes keep the original example. Watch out for the two ValueErrors and the
TypeError.