WEBVTT 00:00.960 --> 00:06.720 In this lecture we'll be understanding about break and continue straight men to these two simple street 00:06.780 --> 00:07.090 men. 00:07.110 --> 00:13.440 If it talk about break that means break is something that will stop the loop or they will get out of 00:13.440 --> 00:13.860 the loop. 00:13.920 --> 00:16.780 If you can understand Greek in a similar manner. 00:16.890 --> 00:18.520 The second thing is continue. 00:18.660 --> 00:23.710 So continue is used to actually skip one iteration from the two. 00:23.970 --> 00:29.700 So that means if I'm using break that means I'm just coming out from that direction and if I'm using 00:29.700 --> 00:33.640 continue that means I just want to skip castration. 00:33.690 --> 00:36.020 So let us form so you can understand. 00:36.270 --> 00:42.770 The first thing is if I'm begging for X that means I'm reading from my list that is it. 00:42.840 --> 00:46.680 And this will be giving me a result of my sequence. 00:46.680 --> 00:48.170 Zero one two three four five. 00:48.360 --> 00:51.720 And if I'm taking a while so I'll start from zero. 00:51.810 --> 00:56.520 If I was less than five I need to print and then increment the value I. 00:56.550 --> 01:00.500 Do I want to check if I is less than five that is done. 01:00.510 --> 01:07.870 That means cutting the value of i is one check that are less than five percent that increase the value 01:07.870 --> 01:09.870 or why go back in jail. 01:10.050 --> 01:11.900 So it will print accordingly. 01:11.910 --> 01:16.020 Let me run this one OK. 01:16.040 --> 01:17.290 I'm doing so. 01:17.420 --> 01:20.960 That means the result is right but I need to differentiate. 01:20.960 --> 01:30.700 So I was out of re-instatement it was Alan. 01:30.800 --> 01:31.880 So let me clear this all. 01:31.870 --> 01:34.310 And now we should start using break. 01:34.580 --> 01:40.610 So the first thing is what if I was searching something inside my list. 01:40.850 --> 01:47.980 So once I find that I need to stop my creation that means I need to stop my loue so it can happen. 01:48.000 --> 01:49.780 So if I don't and if. 01:49.810 --> 01:57.230 Well the reason I was able to find my I don't turn off all numbers or maybe number by him I should stop 01:57.230 --> 02:02.460 there why I shouldn't go for one hundred time or thousand time of attrition. 02:02.660 --> 02:04.780 So we'll be digging the same example. 02:04.910 --> 02:11.260 So suppose I were searching for two or maybe I have some tasks which is dependent on the value of two. 02:11.270 --> 02:20.150 So once two is done I can recall from my new so here what I can do is I can use my IF statement if x 02:20.270 --> 02:22.040 is equal equal through to. 02:22.040 --> 02:26.510 That means I'm able to find this particular element. 02:26.690 --> 02:33.070 Or is this element from I can break out from this new cycle news breaks. 02:33.230 --> 02:35.670 And so let me come in. 02:35.670 --> 02:45.510 All these and other than this one you can see it rendered zero and one that means it started from x 02:45.890 --> 02:47.920 to the first iteration. 02:48.070 --> 02:49.150 To zero. 02:49.210 --> 02:51.980 That means X was not able to do. 02:52.270 --> 02:55.610 The second element trended one to the third element. 02:55.810 --> 03:05.320 And then this condition was true that means x is equal to and then get inside executed this break statement. 03:05.560 --> 03:08.840 Once break straight when that's done it gets out of the loop. 03:09.070 --> 03:16.270 So what I should do is I should come in this one from this again so you can see that once the big statement 03:16.270 --> 03:18.260 is done get out of the loop. 03:18.670 --> 03:23.110 We should also try this with y need to come in this one 03:26.480 --> 03:35.520 so you have more I can do is using the same condition I will break when x is equal to three and if I 03:35.520 --> 03:36.270 run this one 03:39.280 --> 03:42.300 OK I just do the smallest thing I should use. 03:42.300 --> 03:42.620 I 03:46.450 --> 03:53.280 show her I'm falling the same if x is equal street was two three I'm going to break this blue and if 03:53.280 --> 03:54.710 not it will continue. 03:54.920 --> 04:02.890 So if I run this come on you can say it was able to print 0 1 2 and then they break out on the street. 04:02.910 --> 04:08.430 And so this was one of the simple Craigslist Mendus used to get out from the new. 04:08.550 --> 04:10.670 Now the second thing is continue. 04:10.900 --> 04:13.810 Latest excuse me come in this out. 04:14.100 --> 04:15.570 So it's great. 04:15.570 --> 04:24.720 If I use continue play around the score you can see what actually happened is 0 1 3 4 5. 04:24.720 --> 04:32.100 That means when X was equal through two it actually skipped the new folder and just jump on to the next 04:32.100 --> 04:32.980 iteration. 04:33.360 --> 04:35.940 But remember it will skip all the steps. 04:36.120 --> 04:42.170 That means whenever x is going to be do all they step inside the for loop will be OK. 04:42.390 --> 04:45.650 So you need to be careful when placing this condition. 04:45.990 --> 04:52.020 And if I try something similar and Wildblue it will be something similar but there will be at least. 04:52.120 --> 04:58.520 So if I use continue have runners come on you can see I was able to print 0 1 2. 04:58.740 --> 05:06.800 And now my cursor that means it is still pending for some input output while that's happening. 05:06.960 --> 05:08.730 Let me get this out. 05:09.060 --> 05:12.260 So what actually happened is it started with zero. 05:12.270 --> 05:13.230 Everything was fine. 05:13.230 --> 05:14.400 It started with one. 05:14.400 --> 05:16.110 Everything was fine. 05:16.170 --> 05:17.320 Everything was fine. 05:17.550 --> 05:23.760 But when I was 3 it actually came from everything. 05:23.760 --> 05:33.000 Now the value of i is still three because if I skip the printer I skipped this increment value. 05:33.000 --> 05:35.840 That means it was not able to add last one. 05:35.870 --> 05:40.840 So it was still three come back to the statement it was still three jumbo. 05:40.860 --> 05:41.740 Why Lou. 05:41.880 --> 05:43.070 Still three. 05:43.220 --> 05:48.270 Back to my loop's three but it was not able to get our increment in value. 05:48.570 --> 05:50.080 So I need to be careful. 05:50.130 --> 05:58.050 So what I can do is just make this statement and I on the top and then fight on this one. 05:58.250 --> 06:01.730 You can see I was able to bring one two then four and five. 06:02.040 --> 06:07.080 So I was you know go back to the first line that is increment in the value. 06:07.200 --> 06:11.640 So it is now one check out the statement in the dark. 06:11.790 --> 06:18.680 And once I was three it skipped the print statement jumped back to my wife to check the condition increment 06:18.750 --> 06:22.540 the value before and things followed with. 06:22.560 --> 06:24.490 So I need to get all them. 06:24.690 --> 06:29.710 These two are really important and you should know how to use and abuse them.