1 00:00:00,390 --> 00:00:00,990 Welcome back. 2 00:00:01,290 --> 00:00:06,660 Let's keep going with some more stirring methods now we've learned about adding and removing ones. 3 00:00:06,660 --> 00:00:10,890 We learned about append, insert and extend and then removing. 4 00:00:10,890 --> 00:00:13,500 We learned about pop, remove and clear. 5 00:00:14,190 --> 00:00:15,660 There's a few other important ones. 6 00:00:16,670 --> 00:00:18,920 Let's go with the index. 7 00:00:20,270 --> 00:00:23,120 So instead of clearing here, let's clean this up. 8 00:00:24,920 --> 00:00:28,550 And we'll do basket dot. 9 00:00:31,390 --> 00:00:37,360 An index, as you can see, we give it a value, a start and a stop, what does that mean? 10 00:00:37,840 --> 00:00:42,400 Well, we want to say, hey, what index is number two? 11 00:00:44,020 --> 00:00:46,990 If we do index of two and I click run. 12 00:00:48,650 --> 00:00:54,220 It's going to give me one I know this is a little confusing, but it's asking for the index. 13 00:00:54,230 --> 00:00:55,750 Where is number two? 14 00:00:55,850 --> 00:01:02,030 Number two is that index of one, let's change these into letters just so it's more clear. 15 00:01:02,300 --> 00:01:03,560 So we have A B. 16 00:01:06,510 --> 00:01:08,910 D and then finally, E! 17 00:01:10,330 --> 00:01:11,710 And again, if I do. 18 00:01:12,960 --> 00:01:14,430 D here and I click run. 19 00:01:15,520 --> 00:01:23,050 I get an index of three because zero one, two, three, it's on shelf three in our memory and you can 20 00:01:23,050 --> 00:01:29,150 also do a optional parameter here, which is where should we start looking? 21 00:01:29,440 --> 00:01:35,470 So I want you to start looking at index of zero and then finish looking at index of two. 22 00:01:36,130 --> 00:01:38,830 If I do run here, I get an there. 23 00:01:38,860 --> 00:01:45,400 It says, hey, D is not enlist because while we started at index of zero and stopped it index of two. 24 00:01:45,910 --> 00:01:47,890 If I do three and I click run. 25 00:01:48,930 --> 00:01:52,950 No, it stops right before 3:00, so if I do for. 26 00:01:54,460 --> 00:01:55,300 And I click Ron. 27 00:01:56,790 --> 00:01:57,390 There you go. 28 00:01:57,420 --> 00:01:58,440 I get three. 29 00:01:59,600 --> 00:02:02,430 Now, errors are not good in our programs. 30 00:02:02,450 --> 00:02:07,100 Ideally, we don't want to get errors, so how do we avoid this? 31 00:02:07,130 --> 00:02:10,570 What if we're looking for something and we're not sure if it's in the list or not? 32 00:02:11,240 --> 00:02:14,510 There's another nifty way of looking for things in a list. 33 00:02:14,840 --> 00:02:18,200 And this involves what we call a python. 34 00:02:18,200 --> 00:02:18,940 Key word. 35 00:02:19,760 --> 00:02:25,040 A key word is something that you use in Python that, well, already has some meaning. 36 00:02:26,360 --> 00:02:34,100 For example, a key word here, if I go to Python, key words are all these words that already mean 37 00:02:34,100 --> 00:02:34,700 something. 38 00:02:35,030 --> 00:02:38,810 Now we're going to go through them and we haven't seen a lot of them yet. 39 00:02:39,530 --> 00:02:44,400 But you might have seen true right in boolean values to mean something. 40 00:02:44,720 --> 00:02:51,290 So in Python, we can't really use the word true because, well, it already means something. 41 00:02:52,400 --> 00:02:59,600 There's a word called in that, as you can see, as soon as we type means something as a key word in 42 00:02:59,600 --> 00:03:09,290 Python and this is quite nice, we can say, hey, is D. in the basket and if I run this. 43 00:03:10,590 --> 00:03:15,030 I get true, OK, is X in Baskett. 44 00:03:16,750 --> 00:03:25,480 I get false because, well, it doesn't exist and this is actually quite useful and we can even do it 45 00:03:25,480 --> 00:03:26,200 for strings. 46 00:03:26,440 --> 00:03:34,240 For example, if I'm looking for, let's say, the letter, I in a word and let's say it's in. 47 00:03:34,750 --> 00:03:38,500 Hi, my name is Ian. 48 00:03:39,490 --> 00:03:40,690 If I click, run. 49 00:03:42,030 --> 00:03:44,850 I get true because the letter I. 50 00:03:45,150 --> 00:03:46,490 Does exist in this drink. 51 00:03:47,250 --> 00:03:48,990 All right, let's learn another one. 52 00:03:49,170 --> 00:03:52,650 Another one is basket dot count. 53 00:03:54,050 --> 00:04:01,250 And we can count how many times an item occurs, so, for example, if I do D and I click run. 54 00:04:02,210 --> 00:04:10,580 I get one because D only exists once in the list, but if I add another D in here and I click run. 55 00:04:11,670 --> 00:04:18,390 We get to it counts how many time this value occurs in our list, a very, very useful. 56 00:04:19,230 --> 00:04:21,230 All right, a few more still to go. 57 00:04:21,240 --> 00:04:23,910 Let's do some exercises and I'll see you in the next one.