The documentation implies this has a few useful properties:

word[:2]    # The first two characters
word[2:]    # Everything except the first two characters

Here’s a useful invariant of slice operations: s[:i] + s[i:] equals s.

For non-negative indices, the length of a slice is the difference of the indices, if both are within bounds. For example, the length of word[1:3] is 2.

I think we can assume that the range functions act the same for consistency.

Answer from Toomai on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › regarding list slicing: can anyone help me understand the reasoning behind inclusive vs. exclusive indexing with negative vs. non-negative integers?
r/learnpython on Reddit: Regarding list slicing: can anyone help me understand the reasoning behind inclusive vs. exclusive indexing with negative vs. non-negative integers?
April 27, 2019 -

Python beginner here, coming from a Matlab and R background... so there's been a bit of a hurdle for me when it comes to understanding indexing in Python.

My current brain fuck has to do with wrapping my head around indexing and list ranges/slicing. And no amount of Google-fu is helping me here.

Let's say I have a simple list:

list = ["a", "b", "c", "d"]

If I want to take a slice of the list, the end of the range is exclusive when using non-negative values:

print(list[0:1])
['a']

Not super intuitive given my background, but fine. I understand what's going on and generally why it happens.

What I don't understand is why the end of the range is inclusive when using negative indexing:

print(list[0:-1])
['a', 'b', 'c']

It seems that the slice should only include ['a', 'b']: given how Python indexes a range of non-negative values, I would expect the result to only give the list items up to (but not including) the penultimate item in the list.

What's the rationale behind an exclusive range for non-negative values but an inclusive range for negative values?

People also ask

How does slicing on a NumPy array differ from slicing on standard Python lists or strings, in terms of both syntax and functionality?
Slicing on a NumPy array allows for multidimensional indexing, which is not inherently supported in standard Python lists or strings. For example, given a = np.array([[1, 2, 3], [4, 5, 6]]), a[0, :] retrieves the first row [1 2 3], whereas a[:, 1] retrieves the second column [2 5]. This contrasts with lists or strings, which typically support simple one-dimensional slices .
🌐
scribd.com
scribd.com › document › 901028685 › Python-Slicing-Notes
Python Slicing: Inclusive vs Exclusive | PDF
How does slicing a string in Python differ from slicing a list, and what are some examples illustrating these differences?
Slicing a string in Python is similar to slicing a list in terms of syntax but operates on character data rather than numeric or mixed data. For example, for the string text = "PYTHON", slicing with text[1:4] yields 'YTH', while text[::-1] reverses the string to 'NOHTYP', operating similarly to list reversal .
🌐
scribd.com
scribd.com › document › 901028685 › Python-Slicing-Notes
Python Slicing: Inclusive vs Exclusive | PDF
What is the result of slicing a Python list with a negative step value, and how does it affect the sequence?
Using a negative step value in Python slicing reverses the sequence. For instance, given the list numbers = [10, 20, 30, 40, 50, 60], the slice numbers[::-1] results in [60, 50, 40, 30, 20, 10], effectively reversing the list .
🌐
scribd.com
scribd.com › document › 901028685 › Python-Slicing-Notes
Python Slicing: Inclusive vs Exclusive | PDF
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-list-slicing
Python List Slicing - GeeksforGeeks
Python · a = [1, 2, 3, 4, 5, 6, 7, 8, 9] # Get elements from index 1 to 4 (excluded) print(a[1:4]) Output · [2, 3, 4] list_name[start : end : step] Parameters: start (optional): Index to begin the slice (inclusive).
Published   July 23, 2025
🌐
Python Morsels
pythonmorsels.com › slicing
List slicing in Python - Python Morsels
March 8, 2024 - What do you think we might get ... is the start index, and the second item is the stop index. The start index is inclusive, but the stop index is exclusive, meaning Python stops just before the stop index....
🌐
Replit
replit.com › home › discover › how to slice a list in python
How to slice a list in Python | Replit
The slice fruits[1:4] extracts a portion of the list starting from index 1 up to, but not including, index 4. This is a core principle of Python slicing; the start index is inclusive, while the end index is exclusive.
🌐
Analytics Vidhya
analyticsvidhya.com › home › all about python list slicing with examples
All About Python List Slicing With Examples
May 20, 2025 - The basic syntax for list slicing in Python is as follows: new_list = original_list[start:end:step] - `start`: The index at which the slicing should begin (inclusive). - `end`: The index at which the slicing should end (exclusive).
Find elsewhere
🌐
O'Reilly
oreilly.com › library › view › pandas-for-everyone › 9780134547046 › app12.xhtml
L. Slicing Values - Pandas for Everyone: Python Data Analysis, First Edition [Book]
December 15, 2017 - This applies to objects like lists ... to specify both the beginning index and the ending index. This is where the left inclusive, right exclusive terminology comes into play. The left index will be included in the returned range ...
Author   Daniel Y. Chen
Published   2017
Pages   410
🌐
Scribd
scribd.com › document › 901028685 › Python-Slicing-Notes
Python Slicing: Inclusive vs Exclusive | PDF
Slicing in Python allows for extracting a subset of sequences such as lists, strings, tuples, or NumPy arrays using a specified range of indices. The syntax for slicing is sequence[start:stop:step], where 'start' is inclusive, 'stop' is exclusive, ...
🌐
Codecademy Forums
discuss.codecademy.com › frequently asked questions › python faq
Why and how are selecting python list indexes inclusive and exclusive? - Python FAQ - Codecademy Forums
August 13, 2019 - Answer When selecting from a list in python, you may have noticed the saying ‘inclusive’ or ‘exclusive’, this is usually referring to the slice notation mylist[start:stop] where the start index is inclusive but the stop index is exclusive.
🌐
Bas
bas.codes › posts › python-slicing
A Comprehensive Guide to Slicing in Python - Bas codes
January 31, 2022 - That’s just an easy way to remember ... value is inclusive and the end value is exclusive. ... Technically, whenever we omit a number between colons, the omitted ones will have the value of None.
🌐
Medium
medium.com › @krejjas › a-surprising-property-of-python-list-slicing-with-indices-84da3be90643
A surprising property of Python list slicing with indices | by Jasenko Krejić | Medium
September 25, 2025 - You’ve also probably used list slicing — a way to extract a sublist from an existing list. Slicing returns elements between the start index (inclusive) and the end index (exclusive).
🌐
CodeFatherTech
codefather.tech › home › blog › python list slicing: how to use it [with simple examples]
Python List Slicing: How to Use It [With Simple Examples]
December 8, 2024 - Start is equal to 2 and stop is equal to 5. The result is a slice of the original list that goes from index 2 (inclusive) to index 5 (exclusive).
🌐
Roberto Reif
robertoreif.com › blog › 2025 › 7 › 22 › python-lists-slicing
PYTHON LISTS: Slicing — Roberto Reif
October 25, 2025 - This is done by specifying a range within square brackets using the format [start:stop:step]. Start Index: Specifies where the slice begins (inclusive). If omitted, it defaults to 0. Stop Index: Specifies where the slice ends (exclusive).
🌐
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...
🌐
freeCodeCamp
freecodecamp.org › news › slicing-and-indexing-in-python
Slicing and Indexing in Python – Explained with Examples
December 11, 2025 - The 4:9 slice means that we are selecting characters starting from index 4 (inclusive) up to index 9 (exclusive), which correspond to the second word "quick". Similarly, the 10:15 slice means we are selecting characters starting from index 10 up to index 15 (exclusive), which correspond to the third word "brown". Suppose we have a list of numbers and we want to extract all the odd numbers from the list.
🌐
DataCamp
datacamp.com › tutorial › python-slice
Python Slice: Useful Methods for Everyday Coding | DataCamp
January 15, 2025 - Slicing in Python is a method for extracting specific portions of sequences like strings, lists, tuples, and ranges. Slicing can refer to using the built-in slice() function or the even more common bracket notation that looks like this: [start:end:step]. The functionality is a core part of the Python language, so you can perform slicing with or without importing any additional packages.
🌐
Educative
educative.io › answers › how-slicing-works-in-python
How slicing works in Python
If we use the slice’s start and stop, every element between these numbers is covered by the slice. Following are some examples: ... That’s just an easy way to remember that the start value is inclusive and the end value is exclusive.