Python String Slicing
Learn how to extract parts of strings using start, stop, step, negative indexes, and practical slicing patterns.
Sounds useful?
Jump into the interactive version.
No setup. No account. Just Python.
Python String Slicing
Learn how to extract parts of strings using start, stop, step, negative indexes, and practical slicing patterns.
Jump into the interactive version.
No setup. No account. Just Python.
This Block teaches one of Python’s most useful text tools: string slicing. You will learn how to take pieces from the beginning, middle, and end of a string using simple slice syntax like text[:3], text[2:], and text[-4:].
The focus is practical: extracting prefixes, suffixes, initials, filename extensions, middle chunks, and other small text pieces you will actually use while writing Python. You will also meet the optional slice step, including the famous tiny reverse trick: text[::-1].
What you will learn:
text[start:stop]text[:3] and text[3:]text[-3:]text[:-1] and text[:-4]text[::2] and reverse strings with text[::-1]By the end, string slicing should feel less like mysterious bracket magic and more like a small, sharp tool for working with text clearly and confidently.
Ready to practice this in the browser?
> Play now