Strings

A string is an ordered list of characters.

Read characters from a string#

To access a character, use its index between square brackets [].

greeting = "Hello"

print greeting[0]  # "H"
print greeting[1]  # "e"
print greeting[3]  # "l"
Immutability

Although you can read individual characters, you cannot modify them, because strings are immutable.

greeting = "Hello"

greeting[0] = "h"  # Error
More operations

Take advantage of all the functionalities of this collection by exploring its multiple built-in methods.