 What is going on guys? Root from noshow.com here today and we are looking at some more Python. We are continuing to look at loops or those really interesting keywords that allow you to repeat code blocks multiple times while under a certain condition or expression. So today we're going to be checking out for loops. Last video we were looking at while loops and for loops are in my opinion a little bit more powerful because you can do a lot more with them. You can still count like you could in while loops but for loops use a variable all the time rather than the while loop because you could add that while loop like we did with the counter example but you don't even need to be using a while loop with a while loop. I'm sorry you don't have to be using a variable with a while loop. So let's try with the for loop though. Let's get idle started up. I'm going to drag this right over here so you guys can see it and create a new documents and we'll save it as you know let's do something differently today let's name it let's name it file.python yep that looks good to me. Alright I'm going to get my shebang line going on here. You don't really need this if you're on Windows or anything else but I'm going to get started. Okay. Now the for loop has a different syntax I should have included in the little side notes but it does use a variable like I was saying so it uses any name variable you can say counter you can call it incrementer but most programmers try and keep it easy since you might not be using this variable for too much other than counting so most people just kind of call it I this is usually only when you're counting though you can use for loops for a whole another scenario and we're going to go in-depth with that real soon in lots of other video tutorials like the way as soon as my series progresses and that sort of thing we guys we get more in-depth with some of the concepts and some of the subjects and some of the material you're going to be seeing new forms of for loops and that sort of thing but hey okay for I in now we're going to use in that membership that we've heard so much about and now you're going to be seeing the range function now the range function is interesting this is it's usually what we use for counting in in for loops like I've been saying and range takes about three parameters optionally it could take one two three I should say if we hit control backslash we can see a little call tip like we have here we have an optional one called start we can see what we want the program what a what number we want the program to start counting from so we could use zero here stop and stop can be how high you want the number to count up to and you can use a step for how much we should increment every time we add to it so we can do with a single function we can do range we can do a single argument I mean we can do for I in range ten so now it's going to go up to ten while I is less than ten we haven't set a variable we haven't set a value for I yet but Python will be able to recognize and understand what we're trying to get at here in this range it's going to return to you a string of numbers from zero to ten because zero is by default when you don't have those other parameters and it's going to keep iterating through those iterating is kind of what I want to the new terminology that I want to teach you today it'll continue to iterate or go through another iteration each time it's running through the code block once it's running through the code block again and now it has new values because I is different when we print out we are at and we can cat on we can concatenate the string value of I so now we when we actually get a little notification and we use a tab just so we can see this coming out program starts new line copy this get down to the end of the program do it once more with program ends and we'll put a new line here instead so let's run this at five program starts and then we start counting we're at zero one two three four five six seven eight nine so this is kind of a similar example as to what we saw with the while loop except we've indented it because I think it looks pretty so now we can experiment with this range function a little more though we had we know by default it'll start counting from zero and then go up to whatever argument you pass to it so what if we did just from two from two to ten it'll start at two and then continue to go up to ten you can see this over on little side notes but let's try program starts and now we go from two three four five six seven eight nine and it stops before it gets to ten so that makes sense it'll take what we pass the first argument to start from so I is equal to zero equal to two in this case sorry and it'll keep going until it's less than ten or less than that other parameter now we can use a different sort of a different parameter structure and we can use zero to ten and we're gonna increment by fives now this should only run twice you'll have it'll start at zero it'll go to five and then it won't run anymore because it'll be greater than ten at that point so let's try it at five program starts we're at zero and then we're at five and then when we add on if we were to add on to it again we would be at ten and that's less than ten it's I'm sorry that's greater than it's equal to ten it's not it's not less than ten so it's going to stop that but if we actually checked out the value of I when we were done counting what would it be at what do you guys think it's at five so the range function knows whether or not the next calculation will bring it above that range so if it is it won't do it but now we've now that it's at I now that I is at five what if we did this whole iteration again if we pasted this in oh it's not going to let me uh it's not going to let me paste that in what are you saying to me what are you doing whatever I'll just retype it for I in range so you guys have to sit through this ten five print your counting that's plus the string of I put myself a little space there so that looks good so now what if we did all of this once more do you think it'll take that I and go up to it'll do you think it'll take five and then continue to do it again so from zero to ten let's try one more time it goes from zero to five and it goes stays at five but I think it retreats back to zero that's interesting though I think I'm thinking it's setting this first argument that we set it to to I what if we didn't supply that though what if we just go here and then we do it again oh it starts at zero so let's let's sort of dissect or take another look at that range function if we're in the interpreter here the interactive shell and we just type in range let's say ten it's going to return us with a list and this is a new concept I want to be teaching you guys in the next tutorial because it's kind of interesting it's a lot of values it's multiple pieces of data put together into one so we go from zero to one to two so whenever I is in here because I is a variable and it can mean anything it goes from zero to one to two to three to four to five and all these things it's not using the current value of I it's seeing what it finds in here hence the in so that's that's a little bit of an interesting look at counting it with Python in in for loops and now that we're going to get into some later videos and some more concepts and more ideas you'll be able to see it in different different formats and different structures so the for loop is incredibly powerful and I use it almost constantly in my programs so I want you to be able to have the understanding and know that concept but up yep thank you guys for watching and I'll see you again in the next tutorial we can check out some more cool stuff have a great day