2/9/25, 12:50 PM Revolutionizing the Job Market | NxtWave
Cheat Sheet
Loop Control Statements
Control statements alter the sequential execution of a program.
Examples
if-elif-else
while, for
break, continue
Break
Break statement makes the program exit a loop early.
Using Break
Generally, break is used to exit a loop when a condition is satisfied.
In the below example, when the variable
i value equals to 3 the break statement gets executed and stops the execution of the loop further.
Code
PYTHON
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=e322db60-81d5-42bc-910a-5c832956b5a5&s_id=e10a932f-caf… 1/4
2/9/25, 12:50 PM Revolutionizing the Job Market | NxtWave
PYTHON
1 for i in range(5):
2 if i == 3:
3 break
4 print(i)
5 print("END")
Output
0
1
2
END
Break in Nested Loop
Break in inner loop stops the execution of the inner loop.
Continue
Continue makes the program skip the remaining statements in the current iteration and begin the next iteration.
Using Continue
Generally, continue is used to skip the remaining statements in the current iteration when a condition is satisfied.
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=e322db60-81d5-42bc-910a-5c832956b5a5&s_id=e10a932f-caf… 2/4
2/9/25, 12:50 PM Revolutionizing the Job Market | NxtWave
In the below example, when the variable
i value equals to 3 the next statements in the loop body are skipped.
Code
PYTHON
1 for i in range(5):
2 if i == 3:
3 continue
4 print(i)
5 print("END")
Output
0
1
2
4
END
Pass
Pass statement is used as a syntactic placeholder. When it is executed, nothing happens.
Generally used when we have to test the code before writing the complete code.
Empty Loops
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=e322db60-81d5-42bc-910a-5c832956b5a5&s_id=e10a932f-caf… 3/4
2/9/25, 12:50 PM Revolutionizing the Job Market | NxtWave
We can use pass statements to test code written so far, before writing loop logic.
Submit Feedback
https://learning.ccbp.in/course?c_id=a6454e48-d030-4d49-8920-253198052232&t_id=e322db60-81d5-42bc-910a-5c832956b5a5&s_id=e10a932f-caf… 4/4