Strings and Character Data in Python
Python’s strings are ordered sequences of characters. Because of this, you can access individual characters from a string using the characters’ associated index. What’s a character’s index? Each character in a string has an index that specifies its position. Indices are integer numbers that start at 0
and go up to the number of characters in the string minus one.
In the following sections, you’ll learn how to run these two operations on your Python strings.
Indexing Strings
You can access individual characters in a string by specifying the string object followed by the character’s index in square brackets ([]
). This operation is known as indexing.
String indexing in Python is zero-based, which means that the first character in the string