1 00:00:01,060 --> 00:00:06,910 So up until now, we learned that strings can be accessed quite easily. 2 00:00:07,420 --> 00:00:11,890 And using the square brackets, we can access different parts of the string. 3 00:00:12,100 --> 00:00:22,480 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,480 --> 00:00:25,720 we can slice the string however we like. 5 00:00:26,350 --> 00:00:31,390 But we also need to learn another important term that's going to come up again and again throughout 6 00:00:31,390 --> 00:00:32,110 this course. 7 00:00:32,110 --> 00:00:37,240 And as a matter of fact, it's an important concept that as you get more advanced into programming, 8 00:00:37,240 --> 00:00:41,080 you really need to understand what is this concept? 9 00:00:41,110 --> 00:00:44,590 Well, it's this idea of immutability. 10 00:00:44,590 --> 00:00:47,470 It's an important term in programming. 11 00:00:48,610 --> 00:00:51,550 What does immutability mean? 12 00:00:52,410 --> 00:00:55,400 Well, strings and python are immutable. 13 00:00:55,410 --> 00:00:57,660 That means they cannot be changed. 14 00:00:58,320 --> 00:00:59,370 What I mean by that. 15 00:01:00,220 --> 00:01:05,890 Now that we've assigned selfish this value, this string. 16 00:01:06,400 --> 00:01:09,430 Well, I can reassign it, right? 17 00:01:09,430 --> 00:01:11,770 I can say selfish is 100 now. 18 00:01:12,570 --> 00:01:15,570 And if I print selfish. 19 00:01:17,440 --> 00:01:18,640 And I click run. 20 00:01:18,940 --> 00:01:20,200 That works. 21 00:01:20,350 --> 00:01:30,940 But if I instead do something like the first index of selfish is going to equal eight and I click run. 22 00:01:31,750 --> 00:01:37,930 I get an error, I get a typo error saying string object does not support item assignment. 23 00:01:38,670 --> 00:01:39,780 Why is that? 24 00:01:39,810 --> 00:01:42,540 Because strings are immutable. 25 00:01:43,260 --> 00:01:49,020 That is, I cannot change the value of this once it's created. 26 00:01:50,130 --> 00:01:52,430 I can just immediately change it to eight. 27 00:01:52,440 --> 00:01:53,980 One, two, three, four, five, six, seven. 28 00:01:54,000 --> 00:01:56,420 No, it has to stay the same. 29 00:01:56,430 --> 00:02:03,210 The only way that I can remove this or change this is to completely reassign the value. 30 00:02:04,700 --> 00:02:13,250 So that in memory Python removes all of this from our bookshelf of memory and instead just assigns eight 31 00:02:13,820 --> 00:02:18,530 into the zero bookshelf and removes everything else because we don't use it anymore. 32 00:02:19,760 --> 00:02:27,110 Now this idea of immutability is something we'll explore more and more, especially when we start talking 33 00:02:27,110 --> 00:02:28,300 about lists. 34 00:02:28,340 --> 00:02:33,950 But for now, just remember that you can't reassign part of a string. 35 00:02:34,430 --> 00:02:38,630 Once created, it exists like that in that form. 36 00:02:38,660 --> 00:02:42,260 The only way we can change it is to create something new. 37 00:02:42,560 --> 00:02:48,650 We can do selfish plus eight and we can create it that way. 38 00:02:48,740 --> 00:02:53,180 But now this selfish is a whole new string. 39 00:02:53,210 --> 00:03:02,660 This no longer exists, and a whole new shelf space was created for us to use this whole new string. 40 00:03:03,820 --> 00:03:08,290 Again, if this doesn't make sense to you or why it's important just yet. 41 00:03:08,290 --> 00:03:09,220 Don't worry. 42 00:03:09,220 --> 00:03:10,240 We'll get there. 43 00:03:10,390 --> 00:03:12,490 For now, though, I'll see you in the next video. 44 00:03:12,700 --> 00:03:13,300 Bye bye.