Understanding Python list slicing with a step of 3

Quick idea

Slicing grabs parts of a list. You can pick a start, an end, and a step. The step tells Python how many items to skip. A step of 3 means take every third item.

How the syntax works

The basic form is start:stop:step. If you leave start or stop blank, Python uses the edges of the list. The stop value is not included. So stop acts like a boundary, not a target.

Examples

Here are a few simple examples you can run in a Python shell.

my_list = ['a','b','c','d','e','f','g','h','i']

Take every third item from the whole list:

my_list[::3]  # ['a', 'd', 'g']

Start at index 1, then every third item:

my_list[1::3]  # ['b', 'e', 'h']

Take a slice up to index 7, stepping by 3:

my_list[0:7:3]  # ['a', 'd', 'g']

Why use step 3?

It’s handy when you want regular sampling. Maybe you have rows, columns, or repeated groups. Using a step of 3 picks items at a consistent interval. So this means you can extract patterns quickly.

Things to watch for

Remember stop is exclusive. If stop is smaller than start and step is positive, you’ll get an empty list. If you use a negative step, the list goes backward. Index errors don’t happen with slicing. Python just returns what fits.

Quick tips

Use an empty start to begin at the first item. Use an empty stop to go to the end. Change the step to negative to reverse and skip. Test slices in the REPL to see how they behave.

Wrap up

Slicing with step 3 is simple and powerful. Once you try it a few times, it becomes second nature. Try the examples and tweak the numbers. You’ll get the hang of it fast.

Scroll to Top