3.08
Completed
Python String Slicing Python String Slicing

Learn how to extract parts of strings using start, stop, step, negative indexes, and practical slicing patterns.

Python String Slicing

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

String Slicing in 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:

  • Read and write basic slices with text[start:stop]
  • Understand why the start index is included and the stop index is excluded
  • Use missing start and stop values with slices like text[:3] and text[3:]
  • Extract endings with negative indexes, such as text[-3:]
  • Remove endings with slices like text[:-1] and text[:-4]
  • Use step slicing with text[::2] and reverse strings with text[::-1]
  • Recognize common slicing mistakes, including the classic “stop index is excluded” trap

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.

> Start now 131 cards · about 12 min

Ready to practice this in the browser?

> Play now