1 00:00:00,660 --> 00:00:02,970 ‫Instructor: Hi, now we will continue 2 00:00:02,970 --> 00:00:06,240 ‫with the For Loops within the lecture as well. 3 00:00:06,240 --> 00:00:09,750 ‫So, now we managed to get every element 4 00:00:09,750 --> 00:00:12,420 ‫inside of that 'myNumbers' list 5 00:00:12,420 --> 00:00:16,140 ‫and use those to create a new integer 6 00:00:16,140 --> 00:00:18,420 ‫with the help of For Loops. 7 00:00:18,420 --> 00:00:22,950 ‫So, I believe you now understood the importance of For Loops 8 00:00:22,950 --> 00:00:26,610 ‫and the way that they work 9 00:00:26,610 --> 00:00:29,550 ‫very efficiently with the list as well. 10 00:00:29,550 --> 00:00:32,220 ‫So, let me show you something else. 11 00:00:32,220 --> 00:00:36,840 ‫We can write the exact same For Loop like this. 12 00:00:36,840 --> 00:00:41,840 ‫Int number and with a colon, 'myNumbers'. 13 00:00:42,270 --> 00:00:44,310 ‫So, this thing 14 00:00:44,310 --> 00:00:48,660 ‫is very often used with lists 15 00:00:48,660 --> 00:00:52,920 ‫so that they came up with their own notation. 16 00:00:52,920 --> 00:00:55,290 ‫So, how does this work? 17 00:00:55,290 --> 00:00:59,550 ‫It means they take each element inside of 'myNumbers' list 18 00:01:00,870 --> 00:01:05,870 ‫and assign it to a variable code number 19 00:01:06,090 --> 00:01:10,440 ‫and do this as long as there is an element 20 00:01:10,440 --> 00:01:13,020 ‫inside of 'myNumbers' list. 21 00:01:13,020 --> 00:01:15,750 ‫So, this is essentially the same thing 22 00:01:15,750 --> 00:01:18,120 ‫that we have written over here, 23 00:01:18,120 --> 00:01:22,800 ‫but we are not bothering with indexes or something else. 24 00:01:22,800 --> 00:01:27,097 ‫We're just writing 'int number : myNumbers'. 25 00:01:28,200 --> 00:01:30,450 ‫So, this is what will happen. 26 00:01:30,450 --> 00:01:35,450 ‫This is going to produce exactly the same result as before. 27 00:01:36,990 --> 00:01:40,800 ‫And let me do the same thing over here so that you can see. 28 00:01:40,800 --> 00:01:44,370 ‫I'm just gonna print out number. 29 00:01:44,370 --> 00:01:49,080 ‫So, let me comment out this print outline 30 00:01:49,080 --> 00:01:51,330 ‫and we will only see the numbers. 31 00:01:51,330 --> 00:01:54,630 ‫As you can see, it takes elements one by one 32 00:01:54,630 --> 00:01:57,450 ‫and it prints them out. 33 00:01:57,450 --> 00:02:01,290 ‫So, this is very convenient. This is very easy to use. 34 00:02:01,290 --> 00:02:05,220 ‫So, whenever you are decide to use For Loops 35 00:02:05,220 --> 00:02:09,150 ‫with actually lists, you're more than welcome to use this. 36 00:02:09,150 --> 00:02:11,580 ‫Of course, we can do the same thing over here as well, 37 00:02:11,580 --> 00:02:14,970 ‫like divide it by three, multiply it by five, 38 00:02:14,970 --> 00:02:17,640 ‫and you will get the same result. 39 00:02:17,640 --> 00:02:21,330 ‫It's much more easy and it's much more convenient. 40 00:02:21,330 --> 00:02:23,580 ‫So, maybe you can think something like that. 41 00:02:23,580 --> 00:02:27,660 ‫Yeah, we can use For Loops with lists, we understood that. 42 00:02:27,660 --> 00:02:30,840 ‫Can we use For Loops on their own? 43 00:02:30,840 --> 00:02:32,700 ‫Yep, we can use them. 44 00:02:32,700 --> 00:02:35,640 ‫It's not very practical though, I will tell you. 45 00:02:35,640 --> 00:02:38,880 ‫I'm going to show you how you can use them. 46 00:02:38,880 --> 00:02:42,720 ‫You can create a For Loop like with it, in the first place. 47 00:02:42,720 --> 00:02:46,110 ‫You can create a new integer, for example. 48 00:02:46,110 --> 00:02:47,710 ‫And you can just say 49 00:02:49,080 --> 00:02:52,080 ‫as long as a is less than 10, 50 00:02:52,080 --> 00:02:54,330 ‫I'm going to continue doing that. 51 00:02:54,330 --> 00:02:55,170 ‫So, for example, 52 00:02:55,170 --> 00:02:58,140 ‫let me create a new in integer called b 53 00:02:58,140 --> 00:03:01,860 ‫and it's a multiplied by 10 54 00:03:01,860 --> 00:03:05,820 ‫and you can actually print out that b 55 00:03:05,820 --> 00:03:08,280 ‫in order to see the results as well. 56 00:03:08,280 --> 00:03:10,980 ‫So, this will continue 10 times 57 00:03:10,980 --> 00:03:14,190 ‫as long as a is less than 10. 58 00:03:14,190 --> 00:03:18,180 ‫So, let me comment this out and round this. 59 00:03:18,180 --> 00:03:19,013 ‫Here you go. 60 00:03:19,013 --> 00:03:21,990 ‫Now we manage to print out 61 00:03:21,990 --> 00:03:24,720 ‫0, 10, 20, 30, 62 00:03:24,720 --> 00:03:27,540 ‫all the way up to the 90. 63 00:03:27,540 --> 00:03:30,060 ‫Now you know how to work with loops 64 00:03:30,060 --> 00:03:33,030 ‫and you know how For Loops actually work 65 00:03:33,030 --> 00:03:36,240 ‫very well with lists. 66 00:03:36,240 --> 00:03:40,710 ‫So, we are gonna see some other kind of loop as well, 67 00:03:40,710 --> 00:03:44,103 ‫but that's what we're gonna do within the next lecture.