Slicing is one of the most popular Python features. Thus, understanding slicing is key to understand existing code bases. In this tutorial, I’m going to train your slicing skills. Ready? So, let’s go! ?
Watch the Video Python Slicing
Read About Slicing
Slicing is a Python-specific concept for accessing a range of values in sequence types such as lists or strings.
The idea of slicing is simple. Use the bracket notation to access a sequence of elements instead of only a single element. You do this via the colon notation of [start:end]
. This notation defines the start index (included) and the end index (excluded).
Solve the Slicing Code Puzzle
word = "galaxy" print(len(word[1:]))
What is the output of this code snippet?
More than one out of four Finxter users can not solve this puzzle. There are two concepts that are novel for them: the len()
function and slicing.
The len()
function is a handy tool to get the length of built-in Python data types such as strings, lists, dictionaries, or tuples. Learn it once and you will have an easier life in all future coding projects.
You can check whether you solved the puzzle correctly on the Finxter.com app:


While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.