‫Welcome back.
‫Let's keep going with some more string methods.
‫Now we've learned about adding and removing ones.
‫We learned about append, insert and extend.
‫And then in removing, we learned about pop, remove and clear.
‫There's a few other important ones.
‫Let's go with the index.
‫So instead of clearing here, let's clean this up.
‫And we'll do basket dot.
‫Index.
‫An index.
‫As you can see, we give it a value, a start and a stop.
‫What does that mean?
‫Well, we want to say, hey, what index is number two?
‫If we do index of two and I click run.
‫It's going to give me one.
‫I know this is a little confusing, but it's asking for the index.
‫Where is number two?
‫Number two is at index of one.
‫Let's change these into letters just so it's more clear.
‫So we have a B.
‫See.
‫D.
‫And then finally, E.
‫And again, if I do.
‫D here and I click Run.
‫I get an index of three because zero one, two, three, it's on shelf three in our memory.
‫And you can also do a optional parameter here, which is where should we start looking?
‫So I want you to start looking at index of zero and then finish looking at index of two.
‫If I do run here, I get an error.
‫It says, hey de is not in list because well, we started at index of zero and stopped an index of two.
‫If I do three and I click Run.
‫No, it stops right before three.
‫So if I do four.
‫And I click Run.
‫There you go.
‫I get three.
‫Now.
‫Errors are not good in our programs.
‫Ideally, we don't want to get errors, so how can we avoid this?
‫What if we're looking for something and we're not sure if it's in the list or not?
‫There's another nifty way of looking for things in a list, and this involves what we call a python
‫key word.
‫A key word is something that you use in Python that well already has some meaning.
‫For example, a key word here if I go to Python.
‫Key words are all these words that already mean something.
‫Now we're going to go through them, and we haven't seen a lot of them yet, but we might have seen
‫true right in boolean values to mean something.
‫So in Python we can't really use the word true because well, it already means something.
‫There's a word called in that, as you can see, as soon as we type mean something is a key word in
‫python and this is quite nice we can say hey is DX in basket and if I run this.
‫I get true OC is ex and basket.
‫I get false because, well, it doesn't exist.
‫And this is actually quite useful.
‫And we can even do it for strings.
‫For example, if I'm looking for, let's say, the letter I in a word and let's say it's I in.
‫Hi, my name is Ian.
‫If I click Run.
‫I get true because the letter I.
‫Does exist in this string.
‫All right, let's learn another one.
‫Another one is basket dot count.
‫And we can count how many times an item occurs.
‫So, for example, if I do, DH and I click Run.
‫I get one because DD only exists once in the list.
‫But if I add another DH in here and I click run.
‫We get to.
‫It counts how many times this value occurs in our list?
‫Very, very useful.
‫All right.
‫A few more still to go.
‫Let's do some exercises and I'll see you in the next one.