And that might be a little tedious sometimes, and I might not want to have to

call len to figure out how many character are in the string.

So Python does have a shorthand for this.

You are allowed to use negative numbers as indices in Python, okay?

And negative 1 indicates the last element of the string.

So both of these operations should do the same thing, okay?

So if I index using [phraselen -1],

I get the exclamation point at the end of my string.

If I index using the number minus 1, the index minus 1,

I get the exclamation point, okay?

I can also get that fourth character that we looked at before from the end, okay?

So, it's not just that I can use negative 1.

I can use any negative index.

Negative 1 is the last character.

Negative 2 is the second to last character.

Negative 3 is the third to last character, and so on.

So, negative 13 is 13th from the last character or

the fourth from the beginning.

So, let's look at that, and

we do in fact get h by indexing with the number negative 13, okay?

So I can use both positive indices starting from zero to work

from the beginning of the string towards the end.

Or I can use negative indices starting at negative 1,

to work from the end of the string back towards the begging, okay?

But I can't just use any arbitrary number here, okay?

If I go past the end with a positive number, so if I

index phrase with phraselen or 16, okay, that's past the end of the string.

I'm going to get an error.

And you see, in fact, we do.

We get an index error, string index out of range, right?

Hopefully that error makes sense to you.

All right, similarly, if I give too big of a negative number,

I go past the beginning.

I'm going to get basically the same exact error, right?

Index error, string index out of range.

Okay, so I do have to keep my indices within the range that is valid here, okay?

I can't index past the end.

If I'm using positive indices, I can't index

below the beginning in some sense if I'm using negative indices, all right?

So, one way I'd like to sort of help you visualize this is if I take a string that

has five characters, a, b, c, d, e, I can index every character in

two different ways, with both a positive number or a negative number.

So from this table you can see here the character c.

I would get that at index 2, if I'm doing positive indexing.

Or index negative 3, if I'm doing negative indexing, okay?

And hopefully this all makes sense.