Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 3
    If I were to fill out all three indexes explicitly, what would they be? Commented Jul 26, 2015 at 4:57
  • 8
    To get the same result , you cannot fill out all three, you can put <start> as len(a)-1 , but there is no <stop> index you can put to get the first element. Example - a[len(a)-1::-1] . This is because <stop> index is exclusive, that is the element at that index is not taken in, also -1 means the last element , so there is no index that can be used to include the first element , other than leaving it blank Commented Jul 26, 2015 at 4:58
  • 3
    The conversion from int to string might be a hacky way to remove leading zeros in the reversed string Commented Mar 22, 2021 at 5:19
  • @xrisk a[-1:-len(a)-1:-1]) , if you really want to check the values for slice method of an array you can use it, hope this will help Commented Jan 16, 2023 at 6:27

lang-py