0:00
Hey guys, welcome to chapter 3
0:09
In this chapter we will take a glance at loops. Well, a loop in programming is a repetition of a statement or group of statements until
0:19
and unless an event occurs. That event is usually based on a condition or the end of an object
0:27
For loop basically works on iterables. An iterable is an object from which a part or member can be taken at a time
0:37
String, list, etc. Still confused? Let's see a program example. Suppose x equals to a list and that contains 4, 6, 8, 7 and 5
0:52
So now we are going to use a for loop. So for i in x, print i
1:01
i here will hold each item from the list and print that on screen each time the loop executes
1:10
This will continue until the last item of the specified list is displayed
1:17
Let's see another example to print out numbers from 1 to 10
1:23
We can use a range function along with the for loop. So how that looks like
1:30
Well, for i in range, now specify the range 1 to 11 because 11 here, the last digit is
1:40
excluded so we have to use 11 here and then print i
1:46
The i here will hold each value within the range of 1 to 11 and display that on screen
1:53
each time the loop runs. The loop will run until the specified range comes to an end
2:01
Do some practice and that would significantly help you understand the concept of for loop
2:09
Have any questions? Please ask in comments. That was all for now