The syntax is:

a[start:stop]  # items start through stop-1
a[start:]      # items start through the rest of the array
a[:stop]       # items from the beginning through stop-1
a[:]           # a copy of the whole array

There is also the step value, which can be used with any of the above:

a[start:stop:step] # start through not past stop, by step

The key point to remember is that the :stop value represents the first value that is not in the selected slice. So, the difference between stop and start is the number of elements selected (if step is 1, the default).

The other feature is that start or stop may be a negative number, which means it counts from the end of the array instead of the beginning. So:

a[-1]    # last item in the array
a[-2:]   # last two items in the array
a[:-2]   # everything except the last two items

Similarly, step may be a negative number:

a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed

Python is kind to the programmer if there are fewer items than you ask for. For example, if you ask for a[:-2] and a only contains one element, you get an empty list instead of an error. Sometimes you would prefer the error, so you have to be aware that this may happen.

Relationship with the slice object

A slice object can represent a slicing operation, i.e.:

a[start:stop:step]

is equivalent to:

a[slice(start, stop, step)]

Slice objects also behave slightly differently depending on the number of arguments, similar to range(), i.e. both slice(stop) and slice(start, stop[, step]) are supported. To skip specifying a given argument, one might use None, so that e.g. a[start:] is equivalent to a[slice(start, None)] or a[::-1] is equivalent to a[slice(None, None, -1)].

While the :-based notation is very helpful for simple slicing, the explicit use of slice() objects simplifies the programmatic generation of slicing.

Answer from Greg Hewgill on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-list-slicing
Python List Slicing - GeeksforGeeks
Example 2: In this example, we use a negative step (-1) to traverse the list in reverse order and create a reversed copy. ... Explanation: slice a[::-1] starts from the end of the list and moves backward one element at a time, returning a reversed ...
Published: July 16, 2026
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ slicing
Python list slicing (with examples) - Python Morsels
March 8, 2024 - What do you think we might get ... 'pear', 'lemon', 'orange'] With Python's slicing syntax, the first item is the start index, and the second item is the stop index....
Discussions

slice - How slicing in Python works - Stack Overflow
You made a cut before the element ... between those two cuts, a list ['T', 'H', 'O']. ... Save this answer. ... Show activity on this post. Most of the previous answers clears up questions about slice notation. The extended indexing syntax used for slicing is aList[start... More on stackoverflow.com
๐ŸŒ stackoverflow.com
I am confused about Slicing a List.
No. players[0:3] means "start at index 0, go until index 3-1", so that's the first 3 elements of your list. If you want the last 3 you need to use negative indexes. print(players[-3:]) More on reddit.com
๐ŸŒ r/learnpython
17
1
February 11, 2025
A Comprehensive Guide to Slicing in Python
The start/end indexing when going in reverse has always taken a level of extra mental effort that I don't like. Like excluding the first and last item using [1:-1] is intuitive to me, but doing the same in reverse by doing [-2:0:-1] annoys me (though I do get why its like that). That is why I tend to do [1:-1][::-1] instead. More on reddit.com
๐ŸŒ r/Python
40
356
February 1, 2022
List slicing with negative index
On negative step, the default start and stop are reversed. Start is len-1 stop is 0. More on reddit.com
๐ŸŒ r/learnpython
5
2
December 15, 2021
People also ask

Does slicing a Python list create a copy?
Yes. Reading a list slice creates a new list containing references to the selected items. It is a shallow copy, so nested mutable objects are still shared.
๐ŸŒ
boot.dev
boot.dev โ€บ blog โ€บ python โ€บ python list slicing: syntax, examples, and a visualizer
Python List Slicing: Syntax, Examples, and a Visualizer | Boot.dev
Is the stop index inclusive in Python list slicing?
No. The start index is included, but the stop index is excluded. A slice from index 1 to index 4 returns the items at indexes 1, 2, and 3.
๐ŸŒ
boot.dev
boot.dev โ€บ blog โ€บ python โ€บ python list slicing: syntax, examples, and a visualizer
Python List Slicing: Syntax, Examples, and a Visualizer | Boot.dev
How do negative steps work in Python slicing?
A negative step moves backward through the list. The stop bound is still excluded, and omitting both bounds with a step of -1 reverses the list.
๐ŸŒ
boot.dev
boot.dev โ€บ blog โ€บ python โ€บ python list slicing: syntax, examples, and a visualizer
Python List Slicing: Syntax, Examples, and a Visualizer | Boot.dev
๐ŸŒ
Learn By Example
learnbyexample.org โ€บ python-list-slicing
Python List Slicing - Learn By Example
June 20, 2024 - This syntax involves specifying the starting index (where your slice begins), the stopping index (where it ends), and the step size (how many elements you skip between each included element).
Top answer
1 of 16
6666

The syntax is:

a[start:stop]  # items start through stop-1
a[start:]      # items start through the rest of the array
a[:stop]       # items from the beginning through stop-1
a[:]           # a copy of the whole array

There is also the step value, which can be used with any of the above:

a[start:stop:step] # start through not past stop, by step

The key point to remember is that the :stop value represents the first value that is not in the selected slice. So, the difference between stop and start is the number of elements selected (if step is 1, the default).

The other feature is that start or stop may be a negative number, which means it counts from the end of the array instead of the beginning. So:

a[-1]    # last item in the array
a[-2:]   # last two items in the array
a[:-2]   # everything except the last two items

Similarly, step may be a negative number:

a[::-1]    # all items in the array, reversed
a[1::-1]   # the first two items, reversed
a[:-3:-1]  # the last two items, reversed
a[-3::-1]  # everything except the last two items, reversed

Python is kind to the programmer if there are fewer items than you ask for. For example, if you ask for a[:-2] and a only contains one element, you get an empty list instead of an error. Sometimes you would prefer the error, so you have to be aware that this may happen.

Relationship with the slice object

A slice object can represent a slicing operation, i.e.:

a[start:stop:step]

is equivalent to:

a[slice(start, stop, step)]

Slice objects also behave slightly differently depending on the number of arguments, similar to range(), i.e. both slice(stop) and slice(start, stop[, step]) are supported. To skip specifying a given argument, one might use None, so that e.g. a[start:] is equivalent to a[slice(start, None)] or a[::-1] is equivalent to a[slice(None, None, -1)].

While the :-based notation is very helpful for simple slicing, the explicit use of slice() objects simplifies the programmatic generation of slicing.

2 of 16
729

The Python tutorial talks about it (scroll down a bit until you get to the part about slicing).

The ASCII art diagram is helpful too for remembering how slices work:

 +---+---+---+---+---+---+
 | P | y | t | h | o | n |
 +---+---+---+---+---+---+
   0   1   2   3   4   5
  -6  -5  -4  -3  -2  -1

One way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the first character numbered 0. Then the right edge of the last character of a string of n characters has index n.

๐ŸŒ
Boot.dev
boot.dev โ€บ blog โ€บ python โ€บ python list slicing: syntax, examples, and a visualizer
Python List Slicing: Syntax, Examples, and a Visualizer | Boot.dev
3 weeks ago - Our Python practice problems article includes more list-related exercises when you're ready to practice! The full slice syntax is list[start:stop:step]. With all three fields empty, numbers[::] makes a shallow copy of the whole list.
๐ŸŒ
Railsware
railsware.com โ€บ home โ€บ engineering โ€บ indexing and slicing for lists, tuples, strings, other sequential types in python
Python Indexing and Slicing for Lists, Tuples, Strings, other Sequential Types | Railsware Blog
January 22, 2025 - ... >>> nums = [10, 20, 30, 40, 50, 60, 70, 80, 90] >>> some_nums = nums[2:7] >>> some_nums [30, 40, 50, 60, 70] So, here is our first example of a slice: 2:7. The full slice syntax is: start:stop:step.
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_strings_slicing.asp
Python - Slicing Strings
Remove List Duplicates Reverse a String Add Two Numbers ยท Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... You can return a range of characters by using the slice syntax...
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ python list slice | syntax, parameters & uses (+code examples)
Python List Slice | Syntax, Parameters & Uses (+Code Examples)
December 30, 2024 - The Python list slicing syntax has three key parameters: start, stop, and step. Each parameter offers flexibility in determining which part of the list to extract. Letโ€™s explore these in detail: start: The start parameter specifies the index ...
๐ŸŒ
Medium
medium.com โ€บ @pies052022 โ€บ what-is-list-slicing-python-how-it-works-with-examples-a20ad4a0036a
What is List Slicing Python? How it Works With Examples | by JOKEN VILLANUEVA | Medium
February 26, 2026 - When entering slice notation, the following syntax may be used: Start position: is the list index where slicing starts. End position: is the list index where slicing ends. The increment โ€” indicates the number of step sizes.
๐ŸŒ
University of Pittsburgh
sites.pitt.edu โ€บ ~naraehan โ€บ python3 โ€บ mbb8.html
Python 3 Notes: List Slicing
Python 3 Notes [ HOME | LING 1330/2330 ] Tutorial 8: List Slicing << Previous Tutorial Next Tutorial >> On this page: slice indexing with [:], negative indexing, slice and negative indexing on strings. Video Tutorial Python 3 Changes print(x,y) instead of print x, y Python 2 vs.
๐ŸŒ
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 - The first step to using slicing with a Python list is to understand the syntax for slicing: list_slice = original_list[start:stop:step] The first important concept to know is that when you apply the slicing operator to a list you get back another list. The syntax of slicing in Python supports ...
๐ŸŒ
Python Tutorial
pythontutorial.net โ€บ home โ€บ python basics โ€บ python list slice
Python List Slice
October 6, 2020 - Positive values slice the list from the first element to the last element while negative values slice the list from the last element to the first element. In addition to extracting a sublist, you can use the list slice to change the list such as updating, resizing, and deleting a part of the list.
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ all about python list slicing with examples
All About Python List Slicing With Examples
May 20, 2025 - In addition to the basic list slicing syntax, Python provides extended slices that allow us to skip elements while extracting a subsequence. We can select elements regularly by specifying a step value greater than 1.
๐ŸŒ
The Python Coding Stack
thepythoncodingstack.com โ€บ the python coding stack โ€บ a slicing story
A Slicing Story - by Stephen Gruppetta
June 25, 2024 - You can read more about __getitem__() ... does since list is the superclass for TestList. The syntax 2:7 within the square brackets represents a slice object....
๐ŸŒ
Python Central
pythoncentral.io โ€บ how-to-slice-listsarrays-and-tuples-in-python
How to Slice Lists/Arrays and Tuples in Python | Python Central
July 18, 2022 - Getting the first โ€œNโ€ elements from a list with slice is as simple as using the following syntax: ... Letโ€™s take the same list as the example before, and output the first three elements of the list by slicing: [python] items = ['car', 'bike', 'house', 'bank', 'purse', 'photo', 'box'] sub_items = items[:3] print(sub_items) [/python]
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ slicing-and-indexing-in-python
Slicing and Indexing in Python โ€“ Explained with Examples
December 11, 2025 - The syntax for slicing is as follows: ... at the end_index). To slice a sequence, you can use square brackets [] with the start and end indices separated by a colon....
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ examples โ€บ list-slicing
Python Program to Slice Lists
To understand this example, you should have the knowledge of the following Python programming topics: ... The format for list slicing is list_name[start: stop: step].
๐ŸŒ
Pythontutor
pythontutor.net โ€บ home โ€บ python tutorial โ€บ python lists โ€บ python list slicing
Python List Slicing โ€“ Syntax, Examples and Techniques
The general syntax is list[start:stop:step]. The start and stop values define the range, and the optional step controls how the slice moves through the list. No. The stop index is exclusive. Python includes the starting index but stops before the specified stop index.
๐ŸŒ
Kansas State University
textbooks.cs.ksu.edu โ€บ intro-python โ€บ 07-lists โ€บ 05-slicing-lists
Slicing Lists :: Introduction to Python
July 30, 2026 - The method for creating list slices is very similar to how the range() function is used in Python. In effect, if the same values are provided as arguments to the range() function, then it will produce the list of indexes that will be used to generate the list slice. Beyond the simple syntax, ...