-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path18_Break & Continue Statements.py
More file actions
26 lines (14 loc) · 1.22 KB
/
18_Break & Continue Statements.py
File metadata and controls
26 lines (14 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'''
Break & Continue -
In English also, the word 'Break' means Interrupt and the word 'Continue' means resuming after an interrupt.
1. Break Statement -
The break statement STOPS THE LOOP even if the while condition is satisfied.
i.e. In short, it puts a break on the loop and doesn't allow to iterate further.
2. Continue Statement -
The Continue statement STOPS THE CURRENT ITERATION OF THE LOOP and then continues with the next iteration.
i.e. in short, it just stops the current iteration and not the whole loop. and also allows to continue with the further iteration.
3. Use Cases of 'Continue' & 'Break' -
When you are working with a big project, there might occur a situaion where you only need to use the loop partially wihout adding new or removing already existing lines of code. We can easily apply the break statement in your code so that you can partially run it without any sort of error.
OR
In a situation, let's suppose you are working with the while loop printing some lines on the screen and you want to skop an iteration in between others, then you can write the continue statement using a "if" statement that matches your need so that you an skip the specific iteration.
'''