 Hey, what's going on guys brutal and all here and today we're gonna be looking at the range function in Python now The range function was a function that we would always be using when we're like counting with for loops So it's kind of a crucial function and understanding the way that works. It's kind of interesting So let's go ahead and get idle started up and we can take a look. I'm gonna create a new New script here called this file dot Python Should bang line started us are been environment Python class base colon comment ending comment define in its self comment comment pass If If Name is equal to underscore main Yeah, I just I'll just completely switch my tone while I'm speaking The root is going to be the base object. Okay, so now let's define the the range function In our case, it's going to be range of because that's I think that that's I think that's a good name for it And then we can have Start Stop and then step now stop is going to be equal to Zero I'm thinking These are all optional. So I mean step can be equal to one We can kind of experiment and see how it'll go while we're going. So We're gonna want to if Because I feel like we should be setting these in the Well step can stay as one, but if Okay, whatever if stop is equal to zero Stop can be none. I'm thinking Then start should equal zero and stop should equal start If we want to switch these around though because start is going to be the mandatory one So now while Start is less than stop We're gonna use a while loop here because we aren't able to use that for loop to count obviously because we're trying to avoid The range function we can do start plus equals step and then we needed a list here We can define return list Equals Empty it's empty for now and then we can do Returned list Plus equals a list of start now when it's done You can return the returned list Okay, so let's try it now this looks like it'll just go from if we supply any arguments to it It'll go from actually it'll start at zero and then go until whenever we tell it to stop So while stop is less than the stop obviously it'll keep incrementing by the step Whatever we set that to be and then every time it'll change the returned list to whatever the new number is and then we can Return the returned list so it'll work exactly like the range function. Let's try it just a regular range function first We'll try range In our case it can be one. I have an invalid syntax make sure that's a comparison operator and Let's try that same exact thing in our case range of range of one Remember we have to have our self keyword here because it's a local variable. Okay, so this is a difference Let's see what we've got here I'm thinking we're just gonna want to move this to start Now if we tried it in range of two actually, let's set a let's set a variable here to make things easy um Temporary we'll call it. It doesn't matter what we call it in all honesty, so I just mean a temporary We can call this one temporary as well Because I want to be able to see side by side how our function matches up with the original one one five We should run this One two three four good now if we do ten good now if we do Another temporary which will act as our stop rary And be equal to let's say 20. Let's add this one here So run that we go from 10 to 19 good good and we'll set Last temp because I don't want to have to type out temporary again, even though I kind of copied and paste the last one So yeah, and last time can be two So we're going to increment by two each time. Oh Whoopsies Idol is so obnoxious 10 12 14 16 18, okay Look at this line by line We can see how similar our functions are and we're going to want to set the list up to add to the first time because we're Beginning from that zero and the while it's less than this we're gonna want to set that up before we increment So it makes sense when we look at it from the range sense of things because we're starting at Zero or whatever we start with and then we're going to begin with that or at least return begin with a returned list with that So yeah Here we are guys. I hope you understand this. I hope you're able to follow through with this sort of thing in your own code It's just another way of recreating the range function at least showing you how it works in the back end and that's all though I hope maybe you can even think about this and maybe make a better version because I feel like this if statement is a little choppy I feel like maybe we did something with the parameters We might be able to set something up differently But hey, it's it's worthy food for thought as always and I will see you guys in the next tutorial