So up until now, we learned that strings can be accessed quite easily and using the square brackets,
we can access different parts of the string.
And this idea of a start, a stop and a step over is what we call slicing or string slicing, because
we can slice the string however we like.
But we also need to learn another important term that's going to come up again and again throughout
this course.
And as a matter of fact, it's an important concept that as you get more advanced into programming,
you really need to understand what is this concept?
Well, it's this idea of immutability.
It's an important term in programming.
What does immutability mean?
Well, strings in Python are immutable, that means they cannot be changed.
What I mean by that?
Now that we've assigned selfish this value, this string, well, I can reassign it, right, I can
say selfish is one hundred now.
And if I print selfish.
And I click, run, that works, but if I instead do something like the first index of selfish is going
to equal eight and I click run.
I get an error, I get a type error saying string object does not support item assignment.
Why is that?
Because strings are immutable.
That is, I cannot change the value of this once it's created.
I can just immediately change it to eight, one, two, three, four, five, six, seven.
No, it has to stay the same.
The only way that I can remove this or change this is to completely reassign the value.
So that in memory, Python removes all of this from our bookshelf of memory and instead just assigns
eight into the zero bookshelf and removes everything else because we don't use it anymore.
Now, this idea of immutability is something we'll explore more and more, especially when we start
talking about lists.
But for now, just remember that you can't reassign part of a string once created.
It exists like that in that form.
The only way we can change it is to create something new.
We can do selfish plus eight and we can create it that way.
But now this selfish is a whole new string.
This no longer exists and a whole new shelf space was created for us to use this whole new string.
Again, if this doesn't make sense to you or why it's important just yet, don't worry, we'll get there.
For now, though, I'll see in the next video.
Bye bye.