What does extended slice syntax actually do for negative steps? [duplicate]
问题 This question already has answers here : Understanding slice notation (32 answers) Closed 6 years ago . The extended slice syntax in python has been explained to me as " a[n:m:k] returns every kth element from n to m ". This gives me a good idea what to expect when k is positive. But I'm lost on how to interpret a[n:m:k] for negative k. I know that a[::-1] reverses a, and that a[::-k] takes ever kth element of the reversed a. But how is this a generalization of the definition for k positive?