String Slicing

In this lesson, we'll understand what slicing is and how it can be applied to strings.

Definition #

Slicing is the process of obtaining a portion (substring) of a string by using its indices.

Given a string, we can use the following template to slice it and obtain a substring:

  • start is the index from where we want the substring to start.
  • end is the index where we want our substring to end.

The character at the end index in the string, will not be included in the substring obtained through this method.

Get hands-on with 1000+ tech skills courses.