1 00:00:00,630 --> 00:00:02,040 Welcome back now. 2 00:00:02,070 --> 00:00:04,630 Up until now we saw the break. 3 00:00:04,680 --> 00:00:10,500 Key word that we can use to break out of a loop and you see here that we're able to loop with a for 4 00:00:10,500 --> 00:00:13,070 loop but with a while loop as soon as we break. 5 00:00:13,080 --> 00:00:14,220 We're done. 6 00:00:14,220 --> 00:00:21,350 We've just well broken out of the loop but could we do that in a for loop. 7 00:00:21,360 --> 00:00:24,760 Let's find out yep. 8 00:00:24,880 --> 00:00:26,050 Break. 9 00:00:26,050 --> 00:00:36,610 Keyword works in a for loop as well but there's actually two other things that we can use besides break. 10 00:00:36,710 --> 00:00:47,720 One is called continue and you can see here again blue highlighting if I do continue here and I click 11 00:00:47,870 --> 00:00:49,990 Run. 12 00:00:50,050 --> 00:00:50,620 There you go. 13 00:00:50,620 --> 00:00:52,410 We get our looping again. 14 00:00:52,690 --> 00:00:59,780 But you're thinking why why do we need this like it seems completely useless right. 15 00:00:59,800 --> 00:01:01,270 Well a break. 16 00:01:01,420 --> 00:01:06,680 When we use the break segment it breaks out of the current and closing loop. 17 00:01:06,910 --> 00:01:12,050 So when we used a break statement we broke out of this loop. 18 00:01:12,100 --> 00:01:12,460 Right. 19 00:01:12,460 --> 00:01:16,540 This whole while loop we just exited it and same with the for loop. 20 00:01:16,540 --> 00:01:24,370 We completely exited it however with a continue what we're saying is hey whatever happens when you hit 21 00:01:24,370 --> 00:01:28,880 this line continue onto the top of the enclosing loop. 22 00:01:29,020 --> 00:01:31,150 So the current closing loop What is it. 23 00:01:31,180 --> 00:01:32,310 It's this for loop. 24 00:01:32,410 --> 00:01:40,580 So it's going to go back to the for loop so that if I do something like print here so that we get it 25 00:01:40,580 --> 00:01:50,810 printed twice or you know what let's just move print down here like that and then. 26 00:01:50,830 --> 00:01:51,700 Same here. 27 00:01:51,700 --> 00:01:56,620 We're going to just print out the bottom after continue. 28 00:01:56,620 --> 00:02:04,470 If I click Run nothing gets printed because as soon as it sees continue it's going to say OK I'm going 29 00:02:04,470 --> 00:02:10,620 to go back to the loop and it's going to keep going keep going keep going until well the loop ends so 30 00:02:10,620 --> 00:02:18,710 that we never actually hit line 10 in line for so that becomes really useful and conditional logic as 31 00:02:18,710 --> 00:02:19,780 well. 32 00:02:19,790 --> 00:02:28,100 Finally the third one is called Pass and Pass is but not very useful. 33 00:02:28,100 --> 00:02:36,700 It essentially does nothing if I click run here and again it shows me here line 10 something's wrong. 34 00:02:36,700 --> 00:02:45,040 Well we have to move print up to the top so that while we don't get my list of index of three which 35 00:02:45,160 --> 00:02:47,310 doesn't exist. 36 00:02:47,420 --> 00:02:55,250 So again going back here if I click Run pass doesn't do absolutely anything it just essentially passes 37 00:02:55,310 --> 00:02:56,330 to the next line. 38 00:02:57,200 --> 00:03:00,220 So why is that ever useful. 39 00:03:00,230 --> 00:03:07,480 It's very rare that you'll see pass in your code but pass is a good way to have let's say a placeholder 40 00:03:07,550 --> 00:03:13,940 while you're coding for example you want to loop through the for loop but we don't know what we want 41 00:03:13,940 --> 00:03:15,050 to do yet in the code. 42 00:03:15,080 --> 00:03:18,570 Let's say that here we're still thinking about it. 43 00:03:18,770 --> 00:03:29,430 If I do this and I click Run I get an error here because what Whoa well expected an indented block because 44 00:03:29,820 --> 00:03:34,650 now the for loop or the python interpreters looking for the next. 45 00:03:34,650 --> 00:03:36,170 Like what am I supposed to do with the loop. 46 00:03:36,180 --> 00:03:38,460 I'm trying to loop and there's no code for me. 47 00:03:38,550 --> 00:03:46,020 So you can add a pass here to at least fill something for the for loop to say hey I'm thinking about 48 00:03:46,020 --> 00:03:50,790 it I'm just going to pass it for now just so you have something so you don't bug me and I'll come back 49 00:03:50,790 --> 00:03:51,210 to it. 50 00:03:51,240 --> 00:03:54,740 So if I click Run that still works. 51 00:03:54,740 --> 00:04:00,230 So pass is one of those place holders that we can use so that there is a line of code that does absolutely 52 00:04:00,260 --> 00:04:02,330 nothing that we can still pass through. 53 00:04:02,330 --> 00:04:05,150 Again a very rare thing to see in production code. 54 00:04:05,160 --> 00:04:11,960 But while you're developing some developers like using passed and there you have it break continue and 55 00:04:11,960 --> 00:04:12,810 pass. 56 00:04:13,010 --> 00:04:14,290 I'll see you in the next one. 57 00:04:14,360 --> 00:04:14,580 Bob.