A Visual Guide to Python Slices and Indexes

Richard Quinn
Published in
5 min readAug 31, 2020

--

Beginner guide to understanding Python’s slice object.

If you’re unsure about how Python indexes and slices strings, this article is for you! First, let’s explore indexes. (Indices for the grammatically correct!).

This is a companion article to my beginner series:

Python Uses Zero-Based Indexes

The first element in a sequence has the index 0. Not 1. This is often a source of confusion!

Although the first character has the index 0, and the last character has index 11, there are in fact 12 characters in this string.

Access an Index…

--

--

I am a software engineering manager with over 25 years of experience. I am working to improve people’s health. Based in Basel, Switzerland.