Python Jump Statements

Jump statements are used to skip, jump, or exit from the running program inside from the loop at the particular condition. They are used mainly to interrupt switch statements and loops. Jump statements are break, continue, return, and exit statement. 

Jump Statements in Python

  • Break Statement
  • Continue Statement
  • Pass Statement

Break statement

With the help of the break the statement, we can terminate the loop. We can use it will terminate the loop if the condition is true. By the keyword we describe the break statement.

Example of break Statement

We are going to print a series, and we want to stop the loop after executing two time

char = ("a", "b", "c", "d")
for t in char:
   if t == "c":
        break
   print(t)
print("Welcome")
Tutorials Class - Output Window

a
b
Welcome

Note: The break statement only terminates the loop, it does not completely stop the flow of the program.

Python for loop – Continue statement

With the help of the continue statement, we can terminate any iteration and it returns the control to the beginning again. Suppose we want to skip/terminate further execution for a certain condition of the loop. By using the continue keyword we define the continued statement.

Example of continue Statement

We are going to print a series, and we want to skip the loop at the second iteration where ‘b’ character found.

char = ("a", "b", "c", "d")
for t in char:
    if t == "b":
        continue
    print(t)
print("Welcome")
Tutorials Class - Output Window

a
c
d
Welcome

Note: The continue statement only skip on an iteration of the loop, it does not completely stop the flow of the program. Therefore, the statements outside loops will still run if exists.


Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.