‫Instructor: Hi, now we will continue
‫with the For Loops within the lecture as well.
‫So, now we managed to get every element
‫inside of that 'myNumbers' list
‫and use those to create a new integer
‫with the help of For Loops.
‫So, I believe you now understood the importance of For Loops
‫and the way that they work
‫very efficiently with the list as well.
‫So, let me show you something else.
‫We can write the exact same For Loop like this.
‫Int number and with a colon, 'myNumbers'.
‫So, this thing
‫is very often used with lists
‫so that they came up with their own notation.
‫So, how does this work?
‫It means they take each element inside of 'myNumbers' list
‫and assign it to a variable code number
‫and do this as long as there is an element
‫inside of 'myNumbers' list.
‫So, this is essentially the same thing
‫that we have written over here,
‫but we are not bothering with indexes or something else.
‫We're just writing 'int number : myNumbers'.
‫So, this is what will happen.
‫This is going to produce exactly the same result as before.
‫And let me do the same thing over here so that you can see.
‫I'm just gonna print out number.
‫So, let me comment out this print outline
‫and we will only see the numbers.
‫As you can see, it takes elements one by one
‫and it prints them out.
‫So, this is very convenient. This is very easy to use.
‫So, whenever you are decide to use For Loops
‫with actually lists, you're more than welcome to use this.
‫Of course, we can do the same thing over here as well,
‫like divide it by three, multiply it by five,
‫and you will get the same result.
‫It's much more easy and it's much more convenient.
‫So, maybe you can think something like that.
‫Yeah, we can use For Loops with lists, we understood that.
‫Can we use For Loops on their own?
‫Yep, we can use them.
‫It's not very practical though, I will tell you.
‫I'm going to show you how you can use them.
‫You can create a For Loop like with it, in the first place.
‫You can create a new integer, for example.
‫And you can just say
‫as long as a is less than 10,
‫I'm going to continue doing that.
‫So, for example,
‫let me create a new in integer called b
‫and it's a multiplied by 10
‫and you can actually print out that b
‫in order to see the results as well.
‫So, this will continue 10 times
‫as long as a is less than 10.
‫So, let me comment this out and round this.
‫Here you go.
‫Now we manage to print out
‫0, 10, 20, 30,
‫all the way up to the 90.
‫Now you know how to work with loops
‫and you know how For Loops actually work
‫very well with lists.
‫So, we are gonna see some other kind of loop as well,
‫but that's what we're gonna do within the next lecture.