Strings

A str is a sequence of characters. Single and double quotes mean the same thing. Triple quotes make a string that spans lines.

s[0] is the first character and len(s) is the length. Negative indexes count from the end: s[-1] is the last character. An index past the end raises IndexError.

Strings are immutable. s[0] = "J" is a TypeError. To change a string you build a new one. This matters for speed: adding to a string in a loop can copy it each time, which is why "".join(parts) is the idiom.

in checks for a substring: "py" in "happy" is True. Python has no separate character type. s[0] is just a string of length 1.

Run it, then try word[10] to see the error.