The Python tutorial explains slice behavior when indices are negative, but I can't find documentation describing the behavior when the end index precedes the start index. (I've also looked at Explain Python's slice notation, and perhaps I'm not reading carefully enough, but the answers there don't seem to address this point.)
The behavior that I observe is that an empty list is returned, which seems reasonable to me. However, it also would seem reasonable to me for this to return a list of items between i
and j
in reversed order or to simply raise an exception.
Is list[i:j]
guaranteed to be an empty list if list[j]
precedes list[i]
?