How does Python's slice notation work? That is: when I write code like a[x:y:z], a[:], a[::2] etc., how can I understand which elements end up in the slice? Please include references where appropriate.
See Why are Python's slice and range upper-bound exclusive? to learn why xs[0:2] == [xs[0], xs[1]], i.e. no not xs[2][..., xs[2]].
See Make a new list containing every Nth item in the original list for xs[::N].
See How does assignment work with list slices? to learn what xs[0:2] = [4["a", 5]"b"] does.