Yes, calling s[0:-1] is exactly the same as calling s[:-1].

Using a negative number as an index in python returns the nth element from the right-hand side of the list (as opposed to the usual left-hand side).

so if you have a list as so:

myList = ['a', 'b', 'c', 'd', 'e']
print myList[-1] # prints 'e'

the print statement will print "e".

Once you understand that (which you may already, it's not entirely clear if that's one of the things you're confused about or not) we can start talking about slicing.

I'm going to assume you understand the basics of a slice along the lines of myList[2:4] (which will return ['c', 'd']) and jump straight into the slicing notation where one side is left blank.

As you suspected in your post, myList[:index] is exactly the same as myList[0:index].

This is also works the other way around, by the way... myList[index:] is the same as myList[index:len(myList)] and will return a list of all the elements from the list starting at index and going till the end (e.g. print myList[2:] will print ['c', 'd', 'e']).

As a third note, you can even do print myList[:] where no index is indicated, which will basically return a copy of the entire list (equivalent to myList[0:len(myList)], returns ['a', 'b', 'c', 'd', 'e']). This might be useful if you think myList is going to change at some point but you want to keep a copy of it in its current state.

If you're not already doing it I find just messing around in a Python interpreter a whole bunch a big help towards understanding these things. I recommend IPython.

Answer from Redwood on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › slicing-with-negative-numbers-in-python
Slicing with Negative Numbers in Python - GeeksforGeeks
September 18, 2025 - In Python, negative slicing can be done in two ways: Using colon (:) operator · Using slice() function · Both methods allow us to specify the start, end and step positions using negative indices.
Top answer
1 of 9
47

Yes, calling s[0:-1] is exactly the same as calling s[:-1].

Using a negative number as an index in python returns the nth element from the right-hand side of the list (as opposed to the usual left-hand side).

so if you have a list as so:

myList = ['a', 'b', 'c', 'd', 'e']
print myList[-1] # prints 'e'

the print statement will print "e".

Once you understand that (which you may already, it's not entirely clear if that's one of the things you're confused about or not) we can start talking about slicing.

I'm going to assume you understand the basics of a slice along the lines of myList[2:4] (which will return ['c', 'd']) and jump straight into the slicing notation where one side is left blank.

As you suspected in your post, myList[:index] is exactly the same as myList[0:index].

This is also works the other way around, by the way... myList[index:] is the same as myList[index:len(myList)] and will return a list of all the elements from the list starting at index and going till the end (e.g. print myList[2:] will print ['c', 'd', 'e']).

As a third note, you can even do print myList[:] where no index is indicated, which will basically return a copy of the entire list (equivalent to myList[0:len(myList)], returns ['a', 'b', 'c', 'd', 'e']). This might be useful if you think myList is going to change at some point but you want to keep a copy of it in its current state.

If you're not already doing it I find just messing around in a Python interpreter a whole bunch a big help towards understanding these things. I recommend IPython.

2 of 9
19
>>> l = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz&']

# I want a string up to 'def' from 'vwx', all in between
# from 'vwx' so -2;to 'def' just before 'abc' so -9; backwards all so -1.
>>> l[-2:-9:-1]
['vwx', 'stu', 'pqr', 'mno', 'jkl', 'ghi', 'def']

# For the same 'vwx' 7 to 'def' just before 'abc' 0, backwards all -1
>>> l[7:0:-1]
['vwx', 'stu', 'pqr', 'mno', 'jkl', 'ghi', 'def']

Please do not become listless about list.

  1. Write the first element first. You can use positive or negative index for that. I am lazy so I use positive, one stroke less (below 7, or -3 for the start).
  2. Index of the element just before where you want to stop. Again, you can use positive or negative index for that (below 2 or -8 for stop).
  3. Here sign matters; of course - for backwards; value of stride you know. Stride is a 'vector' with both magnitude and direction (below -1, backwards all).

    l = [0,1,2,3,4,5,6,7,8,9]
    l[7:2:-1], l[-3:2:-1], [-3:-8:-1],l[7:-8:-1]
    

    All result in [7, 6, 5, 4, 3].

Discussions

List slicing with negative index
See this stackoverflow thread: Understanding slice notation More on reddit.com
🌐 r/learnpython
5
2
December 15, 2021
Advanced slicing rules?
So I’m taking a quiz and the first question asks something that was never written or spoken once in the section on lists as they pertain to slicing… which is absolutely infuriating as I am someone who tries to understand EVERYTHING before moving on: Question 1: What are the values of list_b ... More on discuss.python.org
🌐 discuss.python.org
1
August 14, 2022
What is slicing in Python? - Python - Data Science Dojo Discussions
Slicing enables the extraction of a designated range of elements from arrays, lists, strings, or tuples using the syntax [start : stop : step]. Here, start denotes the beginning or starting index, stop indicates the ending index, and step determines the interval between elements in the specified ... More on discuss.datasciencedojo.com
🌐 discuss.datasciencedojo.com
1
0
November 9, 2022
Regarding list slicing: can anyone help me understand the reasoning behind inclusive vs. exclusive indexing with negative vs. non-negative integers?
[-1] refers to the last element, so list[0:-1] gives you all but the last element in the same exclusive manner as you saw with positive indices. More on reddit.com
🌐 r/learnpython
9
5
April 27, 2019
🌐
Python.org
discuss.python.org › python help
Negative Slicing in Python - Python Help - Discussions on Python.org
September 8, 2023 - In this code, -1 index is 3, and -2 index is 2, right? But since we don’t include the second index itself, then we only have one value which is 3. However, why is the result an empty list? nums = [1,2,3] vals = nums [-1…
🌐
W3Schools
w3schools.com › python › gloss_python_string_negative_indexing.asp
Python String Negative Indexing
❮ Python Glossary · Use negative indexes to start the slice from the end of the string: Get the characters from position 5 to position 1, starting the count from the end of the string: b = "Hello, World!" print(b[-5:-2]) Try it Yourself » ...
🌐
Reddit
reddit.com › r/learnpython › list slicing with negative index
r/learnpython on Reddit: List slicing with negative index
December 15, 2021 -

Although I know how slicing works but following examples kind of stumped me.

values = [3,4,3,7,8,9,5]
values[:3:-1]    #o/p [5,9,8]
values[5:3:-1]    #o/p [9,8]

I always thought in list[start:stop:step], 'start' defaults to 0, 'stop' defaults to length-1 and 'step' defaults to 1. But this doesn't make sense here. What are the rules? Link to official docs will also be appreciated as I couldn't find that.

🌐
Sentry
sentry.io › sentry answers › python › python slice notation
Python slice notation | Sentry
October 21, 2022 - In the example below, a string is sliced starting at index 2, stopping when the array is complete, and taking the values at every second step. ... Slicing can use negative indexing.
Find elsewhere
🌐
PREP INSTA
prepinsta.com › home › python tutorial › slicing with negative numbers in python
Slicing with Negative Numbers in Python | PrepInsta
September 9, 2023 - #Initialize the String String = 'PrepInsta' #Slicing using 1 negative index arr = String[-2:] print(arr) #Slicing using 1 negative index arr = String[:-3] print(arr) #Slicing using 3rd negative index arr = String[::-1] print(arr) #Slicing using 2 negative indexes arr = String[-9:-4] print(arr) ... The list is a data-type in Python programming language.
🌐
TutorialsPoint
tutorialspoint.com › what-is-a-negative-indexing-in-python
What is a Negative Indexing in Python?
August 25, 2023 - If the values above are in negative, that would mean negative indexing i.e. slicing from the end of the string. # Create a String myStr = 'Thisisit!' # Display the String print("String = ", myStr) # Slice the string # Negative Indexing print("String after slicing (negative indexing) = ", ...
🌐
Shiksha
shiksha.com › home › it & software › it & software articles › programming articles › slicing in python
Slicing in Python - Shiksha Online
November 25, 2022 - In string1[5, 1, -1], the upper bound and the lower bound are essentially reversed. And a negative stride indicates we start slicing from right. The slice string1[5, 1, -1] fetches the items from 2 to 5, in reverse order
🌐
W3Schools
w3schools.com › python › python_strings_slicing.asp
Python - Slicing Strings
Use negative indexes to start the slice from the end of the string: ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an error, or if ...
🌐
Python.org
discuss.python.org › python help
Advanced slicing rules? - Python Help - Discussions on Python.org
August 14, 2022 - So I’m taking a quiz and the first question asks something that was never written or spoken once in the section on lists as they pertain to slicing… which is absolutely infuriating as I am someone who tries to understand EVERYTHING before moving on: Question 1: What are the values of list_b and list_c after the following snippet? list_a = [1, 2, 3] list_b = list_a[-2:-1] list_c = list_a[-1:-2] To me this answer would be: list_b = [2,3] list_c = [3,2] … but that is not one of the answer...
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-slicing
Python List Slicing - GeeksforGeeks
Explanation: The negative step (-1) indicates that Python should traverse the list in reverse order, starting from the end. The slice a[::-1] starts from the end of the list and moves to the beginning which result in reversing list.
Published   July 23, 2025
🌐
YouTube
youtube.com › watch
Python Tutorial for Beginners 17 - Python Slice and Negative index - YouTube
In this video I am going to show How to use Slice function or slicing with Python Collections. Also I am going to show how to use Negative index with Python ...
Published   September 5, 2018
🌐
LabEx
labex.io › tutorials › python-how-to-slice-lists-with-negative-indices-435398
How to slice lists with negative indices | LabEx
Learn powerful Python list slicing techniques using negative indices to efficiently extract and manipulate list elements from the end of the sequence.
🌐
EITCA
eitca.org › home › how do negative indexes work in python when accessing elements in a list?
How do negative indexes work in Python when accessing elements in a list? - EITCA Academy
August 3, 2023 - Slicing with negative indexes works in the same way as slicing with positive indexes, but the start and end points are specified relative to the end of the list. For example, if we want to extract the last three elements of the list, we can use the slice -3: (which is equivalent to [3, 4, 5]): ...
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › python slicing
Master Python Slicing: A Complete Guide for Beginners
October 16, 2024 - Slicing with a negative step value, like `string[::-1]`, can reverse the string, making it a versatile tool for string manipulation. In Python slicing, `start` defines where the slice begins, `stop` indicates where it ends (but doesn’t include ...
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
What is slicing in Python? - Python - Data Science Dojo Discussions
November 9, 2022 - Slicing enables the extraction of a designated range of elements from arrays, lists, strings, or tuples using the syntax [start : stop : step]. Here, start denotes the beginning or starting index, stop indicates the …