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 a 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 8 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't 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 8 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 by.