Strings as lists

In many ways, strings act as a list of their composite characters. Let’s compare:

# TODO: run me
word = "hello"
word_as_list = ["h", "e", "l", "l", "o"]

# TODO: same length?
print(len(word))
print(len(word_as_list))

# TODO: same indexing?
print(word[0])
print(word_as_list[0])
print(word[2])
print(word_as_list[2])
print(word[4])
print(word_as_list[4])

That’s pretty much it for this section. When we learn about for loops, we’ll see how we can treat lists and strings as the same in that context as well.