 Hey, what's going on guys root from no shell.com here today, and I'm gonna be bringing you back with some more python tutorials Let's get idle started. I'm gonna create a new script here Save this as file.python Let's get our shebang line started usr bin environment Python create a class here class can be a I'm gonna call mine base Obviously, you can name yours whatever you'd like Define a constructor passing the self keyword that we always need when we're creating a new function inside of a class And we can test if this is the current script We are running if name is equal to a main so we don't have any import or like include problems And then we can set up roots which is going to be an instance of our base class I know let's get to programming or at least getting back inside of our constructor for a class What we're gonna do is a create a new array or at least a new list. I'm gonna call mine self dot list Nick and that can be with the values of this is a And then list right here at the end So now what we can do is print out the list self dot list And we can concatenate on some new line characters after we converted the string into I'm sorry converted the list into a string So if we run this we get this is a list now Let's take a look at the function. We're gonna be looking at today What we're gonna be taking a look at is is the count function So if we ran self dot list and we use our dot selector to get a function that is inside of that class or the objects That object structure what we can be looking at is the count function You would pass in the argument that you're looking for or at least a value that you're looking for So we could pass in is no return the number or the count of how many times that it's found inside the list So if we run this we get one because we see is in there once if we just pass an I We're gonna get zero because we don't see any I as a single element or a single value inside the list If we do is and we added another one inside the list though If we did is we would get to because obviously now we've found two of them So let's try and recreate this all on our own Let's define a new function. I'm gonna call mine count. We're gonna have to pass in the self variable Obviously, we're gonna need the array to be working with and the value that we're looking for So now we're gonna set up a counter variable and this is going to be the integer that we're gonna be returning whether or not we Or at least how many times that we find the value that we're looking for So we're gonna start it off at zero because we haven't found anything yet And then we're gonna begin to loop through everything inside the array So for item in array and then for each time we can test if the item is equal to the value Or what it is that we're looking for now if it is we can just go ahead and Increase counter counter plus equals one because we found it and then when we're done looping we can just go ahead and return Counter what are how many things that we found? So if we go back into our constructor and we try this out We can print out self dot count. We can pass in self dot list and we can look for is We're gonna get one from the first function and then one from our function as well Because they're practically doing the same thing if we change these to look for I once again We're gonna be returned with zero if we if we look for is Once more except we add another is into our list It'll find it twice because it's obviously found this value twice inside of the list so the function here is pretty simple all this is a simple loop and Just testing if we find things then returning the integer that we've been using to keep track. So there you go This one is very simple. I hope you guys enjoyed this video Enjoy this tutorial you were able to understand or at least take another look at the count function You may not have known it existed, but hey now you do and knowing is half the battle All right anyway guys, I'll see you again in the next video. Bye