In Python, I'm wondering why slices work the way they do. Why did Guido van Rossum define a[start:end]
to include a[start]
but not a[end]
, or as in the title, why does a[0:1]
only contain the first element and not the first two?
This seems like a step back from MATLAB's indexing behavior.
EDIT: The reason I asked this question is that it is confusing that a[0:0]
is empty. But I didn't design a popular language, so what do I know.