Biton iterations using four.
So the for loops index in Biton, the for loop in Python is used to iterate over a sequence, a sequence,
maybe at least maybe a couple, maybe a string or any other iterable objects.
So iterating over the sequence is also known as a traversal.
That was for each and every looping.
It will pick up one element from the iterator and that element can be processed.
So here is that aspect of syntax for for.
So for Val in sequence, don't forget to give this colon here.
And if we get this colon, then automatically the next in line will have some indented.
So body of what you can have the multiple statements you can write, but with the same indentation in
that case.
So here is a flowchart.
So for each item in sequence, last item list, if it is not, the body of four will get executed on
that item, which has been picked up in the last item has been missed, then it will exit loop.
So in this way, the respective flowchart will be working on this for loop syntax in Python.
We can also do this one using that range function so we can generate a sequence of numbers using range
function.
So for Loop can be operating on a certain sequence that is the eight objects and also using this range
function to range, then will generate numbers from July to nine.
So that is the ten numbers we are having here.
So already Bimba here, Distin will not be inclusive.
So 029 that the ten numbers we're having so we can also define the start, stop and Stepaside as range.
This is a start, comma, stop, comma, step side.
So this is Dipset.
Defaults is one if it is not provided if you like.
This one has range one comma ten comma one.
That means it'll, it'll have the values ranging from one to nine and with the increment of one in that
case for loop with the ls s..
So four for loop can also have an optional else block.
The eighth part is executed when the items in the sequence used in for loop exhausts.
So in that when the when the sequence will get exhausted then the else part will get over the control.
So break stickman can be used to stop a for loop.
In such case that else part will be ignored on the other end.
So hence a for loops else part runs if no break occurs.
So if there is a break then the spot will not be executed.
Israel's part will be executed when the spot will be executed, when the sequence will get exhausted.
So let us go for some practical demonstration to show you that how this force can be used in Python
code.
Let us find that how far Loop can work and Python.
So here you have to find one.
At least we know that list elements are to be separated by commas and they are to be enclosed within
this code brackets.
So this is our list here.
So printing all elements present in a set and had this particular set is nothing, but at least so for
I in a print that in each and every iteration, in each and every loop in this particular form using
this for we are picking up one element from that list at the time and the respective element is going
to get printed.
So here is the outcome for this code.
So the first iteration, it is picking up one, then two, then three at that atlas.
It is picking a fight so that lists all this list.
Members are to be picked up to be to be read from the list in the order in which they are appearing
in the list.
So that is our fault.
So for I in so this is a syntax syntax, the grammar to write this for, so for I in a then colon so
colonially indicate that next step will be under this body.
So you can find that if you write here print say hello.
That is also coming within this form so we can find that it is printing like this.
So I want to bring this one and hello side by side so we can go for this.
It is not like this one and then you can print this, hello?
So what will happen?
This one and Halo will get printed in the same line.
So in this way, you can write so many different statements with this indentation to indicate that all
the statements are within the four block.
Let us go for the next one here.
We're using four.
But using this range, we know that here we are given the range that is six Kharma 11, that was a value
up.
I would be ranging from six to 10.
So let me go for the execution.
You see the IIS being initialized with six to 10 for each and every time iteration after that so we
can put some step peloso here to stabilize to that when the increment value is to here.
So now it will go on picking up six, eight and 10 because 11 is not inclusive.
And that's why it will print the values from six to 10.
And with this increment factor of two in this way, you can write this for and using this range function
in our volume.
So let us go for another another way.
So how to write this one?
You can find that it wasn't for loop for printing the values present in the table and using the Ellspermann
in the for loop.
So how to do that one you can print sick.
So this outcome we're having so basically to 11, 12, 13, 14 and 15, so they are coming here and
this is nothing but a double for I.
Inbee So it would be picking up the values from this one value at a time in each and every iteration.
And when this particular you get exhausted, the else block will get to control and then printing completed,
that message is going to get printed.
So there is another way to write a for loop in our python coding.
So in this demonstration, we have shown you that how to write for in Python code to have some block
to get executed repeatedly for multiple number of times.
Thanks for watching this video.