Cats Cradle Indexing and Slicing

Strings (and other sequential data types) are divided into pieces called elements that are stored in order (in a sequence). In a string, each character is one element. You manipulate the individual elements by using operations called indexing and slicing.

An index number specifies the location of a particular element, and a range of index numbers specifies a slice of several elements.

This section describes the basics of indexing and slicing. You also find out some shortcuts and discover how to use slices to make copies of strings.

REMEMBER Strings can't be changed. But you can use slicing to make a new string based on part of an existing string.

Was this article helpful?

0 0

Post a comment