Jump Statements in Python Last Updated : 22 Apr, 2023 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice In any programming language, a command written by the programmer for the computer to act is known as a statement. In simple words, a statement can be thought of as an instruction that programmers give to the computer and upon receiving them, the computer acts accordingly. There are various types of statements in programming and one such type of statement is known as Jump Statement. So, this article contains what a jump statement is, its types, its syntax, and a few programs based on them. Jump Statement: As the name suggests, a jump statement is used to break the normal flow of the program and jump onto a specific line of code in the program if the specific condition is true. In simple words, it transfers the execution control of the program to another statement if a specific condition associated becomes true. As we proceed further you will get a better understanding of this concept. Types of Jump Statements: Break: As the name suggests, a break statement is used to break or stop a flow control. This is generally used in a loop. A break statement is used in a loop in such a way, that when a particular condition becomes true, the break statement is executed and we come out of the loop immediately at that moment. Syntax: Loop{ Condition: break } Example: Python3 # for loop traversing from 1 to 4 for i in range(1, 5): # If this condition becomes true break will execute if(i == 3): # Break statement will terminate the entire loop break print(i) Output1 2Continue: The continue statement is somewhat similar to the break statement but there is one significant difference between them. A break statement terminates the entire loop but the continue statement skips only the current iteration and continues with the rest steps. So, if we use the continue statement in a loop, it will only skip one iteration when the associated condition is true and then continue the rest of the loop unlike the break statement. Syntax: while True: ... if x == 100: continue print(x) Example: Python3 # for loop traversing from 1 to 4 for i in range(1, 5): # If this condition becomes true continue will execute if(i == 2): # Continue statement will skip the iteration when i=2 and continue the rest of the loop continue print(i) Output1 3 4 Pass: The pass statement is an interesting statement, as when it gets executed nothing happens. It plays the role of a placeholder. This means that, if we want to write a piece of code over there in the near future but we cannot keep that space empty, then we can use the pass statement. In simple words, it is used to avoid getting an error from keeping an empty space. Syntax: def function: pass Example: Python3 # Traversing through every character of the string for alphabet in 'Legends': # If alphabet='g' program will do nothing and won't print the letter if(alphabet == 'g'): pass else: print(alphabet) OutputL e e n d sreturn: A return statement is also one type of jump statement. "return" statement terminates a function and returns a value to the calling function. That means the return statement is overall used to invoke a function so that the passed statements can be executed. Syntax: def fun(): statements . . return [expression] Python3 # Python program to demonstrate the # return statement # Function to multiply the two numbers # x and y def multiply(x, y): # returning the multiplication # of x and y return x * y # Driver Code result = multiply(3, 5) print(result) Output15 Comment More infoAdvertise with us Next Article Jump Statements in Python S shreyasnaphad Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2022 Practice Tags : python Similar Reads Jump Statements in Programming Jump statements in programming allow altering the normal flow of control within a program. These statements provide a way to transfer the execution to a different part of the code, facilitating conditional exits, loop control, function return, or unconditional jumps. Table of Content What is a Jump 6 min read Jump statements in C++ Jump statements are used to manipulate the flow of the program if some conditions are met. It is used to terminate or continue the loop inside a program or to stop the execution of a function.In C++, there is four jump statement:Table of Contentcontinue Statementbreak Statementreturn Statementgoto S 4 min read Jump Statements in Java Jumping statements are control statements that transfer execution control from one point to another point in the program. There are three Jump statements that are provided in the Java programming language: Break statement.Continue statement.Return StatementBreak statement1. Using Break Statement to 5 min read Stack in Python A stack is a linear data structure that stores items in a Last-In/First-Out (LIFO) or First-In/Last-Out (FILO) manner. In stack, a new element is added at one end and an element is removed from that end only. The insert and delete operations are often called push and pop. The functions associated wi 8 min read Monotonic Stack in Python A Monotonic Stack is a data structure used to maintain elements in a monotonically increasing or decreasing order. It's particularly useful in problems like finding the next or previous greater or smaller elements. In this article, we'll learn how to implement and use a monotonic stack in Python wit 3 min read Loop Control Statements Loop control statements in Python are special statements that help control the execution of loops (for or while). They let you modify the default behavior of the loop, such as stopping it early, skipping an iteration, or doing nothing temporarily. . Python supports the following control statements:B 4 min read Alternatives to Case/Switch Statements in Python In many programming languages, the case or switch statement is a control flow mechanism that allows a variable to be tested for equality against a list of values, with each value associated with a block of code to be executed. However, Python does not have a built-in case or switch statement. Instea 3 min read turtle.sety() function in Python The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support. turtle.sety() This method is used to set the turtle's second coordinate to y, leavi 1 min read Making Label Jump using PyQt5 in Python Prerequisite: Introduction to PyQt5 PyQt5 is cross-platform GUI toolkit, a set of python bindings for Qt v5. One can develop an interactive desktop application with so much ease because of the tools and simplicity provided by this library. NOw, we will see how we can make the label jump. Sometimes 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw) In C#, Jump statements are used to transfer control from one point to another point in the program due to some specified code while executing the program. In, this article, we will learn to different jump statements available to work in C#.Types of Jump StatementsThere are mainly five keywords in th 4 min read Like