Python Tutorials · Python Strings

Slicing Strings

Learn all about Slicing Strings in this comprehensive tutorial.

5 min read beginner
  • You can return a range of characters by using the slice syntax.
  • By leaving out the start index, the range will start at the first character:
  • By leaving out the end index, the range will go to the end:

Slicing

You can return a range of characters by using the slice syntax.

Specify the start index and the end index, separated by a colon, to return a part of the string.

python
Note: Note: The first character has index 0.

Slice From the Start

By leaving out the start index, the range will start at the first character:

python

Slice To the End

By leaving out the end index, the range will go to the end:

python

Negative Indexing

python

Module quiz

2 questions
1

Which of the following is true about Slicing Strings?

2

What is the most common pitfall when working with Slicing Strings?

Answer all questions to submit.