1 00:00:01,160 --> 00:00:09,200 So up until now, we learned that strings can be accessed quite easily and using the square brackets, 2 00:00:09,200 --> 00:00:11,700 we can access different parts of the string. 3 00:00:12,260 --> 00:00:22,520 And this idea of a start, a stop and a step over is what we call slicing or string slicing, because 4 00:00:22,520 --> 00:00:25,550 we can slice the string however we like. 5 00:00:26,450 --> 00:00:31,430 But we also need to learn another important term that's going to come up again and again throughout 6 00:00:31,430 --> 00:00:32,000 this course. 7 00:00:32,150 --> 00:00:37,220 And as a matter of fact, it's an important concept that as you get more advanced into programming, 8 00:00:37,220 --> 00:00:40,890 you really need to understand what is this concept? 9 00:00:41,270 --> 00:00:44,420 Well, it's this idea of immutability. 10 00:00:44,630 --> 00:00:47,300 It's an important term in programming. 11 00:00:48,600 --> 00:00:51,390 What does immutability mean? 12 00:00:52,540 --> 00:00:57,470 Well, strings in Python are immutable, that means they cannot be changed. 13 00:00:58,300 --> 00:00:59,200 What I mean by that? 14 00:01:00,300 --> 00:01:09,720 Now that we've assigned selfish this value, this string, well, I can reassign it, right, I can 15 00:01:09,720 --> 00:01:11,640 say selfish is one hundred now. 16 00:01:12,670 --> 00:01:15,400 And if I print selfish. 17 00:01:17,490 --> 00:01:26,880 And I click, run, that works, but if I instead do something like the first index of selfish is going 18 00:01:26,880 --> 00:01:30,720 to equal eight and I click run. 19 00:01:31,770 --> 00:01:37,800 I get an error, I get a type error saying string object does not support item assignment. 20 00:01:38,800 --> 00:01:39,580 Why is that? 21 00:01:39,940 --> 00:01:42,370 Because strings are immutable. 22 00:01:43,320 --> 00:01:48,870 That is, I cannot change the value of this once it's created. 23 00:01:50,140 --> 00:01:53,870 I can just immediately change it to eight, one, two, three, four, five, six, seven. 24 00:01:54,020 --> 00:01:56,220 No, it has to stay the same. 25 00:01:56,530 --> 00:02:03,040 The only way that I can remove this or change this is to completely reassign the value. 26 00:02:04,780 --> 00:02:12,700 So that in memory, Python removes all of this from our bookshelf of memory and instead just assigns 27 00:02:12,700 --> 00:02:18,370 eight into the zero bookshelf and removes everything else because we don't use it anymore. 28 00:02:19,870 --> 00:02:26,770 Now, this idea of immutability is something we'll explore more and more, especially when we start 29 00:02:26,770 --> 00:02:28,020 talking about lists. 30 00:02:28,510 --> 00:02:35,590 But for now, just remember that you can't reassign part of a string once created. 31 00:02:35,920 --> 00:02:38,440 It exists like that in that form. 32 00:02:38,770 --> 00:02:42,100 The only way we can change it is to create something new. 33 00:02:42,730 --> 00:02:48,420 We can do selfish plus eight and we can create it that way. 34 00:02:48,910 --> 00:02:52,990 But now this selfish is a whole new string. 35 00:02:53,380 --> 00:03:02,500 This no longer exists and a whole new shelf space was created for us to use this whole new string. 36 00:03:03,840 --> 00:03:10,030 Again, if this doesn't make sense to you or why it's important just yet, don't worry, we'll get there. 37 00:03:10,530 --> 00:03:12,300 For now, though, I'll see in the next video. 38 00:03:12,810 --> 00:03:13,170 Bye bye.