Simple answer about difference: 0 and -0 are equal. So counting from end can’t start with -0 and starts with -1. This makes all subsequent indexes different from zero-based indexing used in forward direction.
EDIT: there is subtle distinction between 0 and None:
Some rules of thumb:
sequence[start:stop:step]
- sequence is object to be sliced
- start, stop, step are indices
- start index is included in slice, end index is first not included
- start, stop and step are separated by :
- to define stop and/or step previous indices must be defined
- if value omitted Python interprets it as None ([2:] to end; [:2] from start) which is different from 0 (specific index)
EDIT: there is subtle distinction between 0 and None:
>>> s = 'python' >>> s[0:0] '' >>> s[None:None] 'python' >>> s[:] # same as [None:None] 'python'You can omit start and stop indices, Python interprets these omissions as None (or in spoken language: 'from start', 'till end').
Some rules of thumb:
sequence[start:stop:step]
- sequence is object to be sliced
- start, stop, step are indices
- start index is included in slice, end index is first not included
- start, stop and step are separated by :
- to define stop and/or step previous indices must be defined
- if value omitted Python interprets it as None ([2:] to end; [:2] from start) which is different from 0 (specific index)
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.