batman = "Bruce Wayne" first = batman # Accessing the first character print(first) space = batman # Accessing the empty space in the string print(space) **last = batman[len(batman) - 1]**
# The following will produce an error since the index is out of bounds
# err = batman[len(batman)]
In the bolded code, why is “e” printed instead of “n” as the output?
I read the [len(batman) - 1] to simplify to [11 - 1] as the length of (batman) is 11 characters. So, shouldn’t print(last) where last = batman end up at the “n” rather than the “e”? As in, the blank space is included in the character count, correct?