Jump Statement in Python | Python
Jump Statement in Python :
In Python, jump statements are used to change the flow of a loop, such as when you wish to skip a section or end a loop.
Three types of jump statements are available in Python. It’s them,
- break
- continue
- pass
1. BREAK Statement:
Iterative statements (loops) like for and while can be ended using the break statement. When this statement is used, the loop’s execution is instantly stopped, and the program then moves on to the next statement.
SYNTAX 1 :
while condition 1:
statement1
statement2
if condition 2:
break
SYNTAX 2:
var in sequence for:
statement1
statement2
if condition
break
CONTINUE STATEMENT:
To return to the top of iterative statements (loops) like for and while, use the continue statement to resume the loop’s execution. The use of this statement terminates the loop’s remaining statements right away.
PASS STATEMENT:
When a programmer doesn’t want to run a block of code, they utilize the pass statement. pass is a null operation. Therefore, when the pass statement has been run, nothing will happen. The pass statement is typically used by programmers when they just want the syntactical expressions and not the code to run.