Jump Statements are used to pass the program’s control from one location to another. This means these are used to modify the flow of a loop like-to skipping a part of a loop or terminating a loop.
It is used to terminate the loop.
for val in "string": if val == "i": break print(val)
In the above code, we break the loop as soon as “i” is encountered, hence printing “str”.
It is used to skip all the remaining statements in the loop and transfer controls back to the top of the loop.
for val in "init": if val == "i": continue print(val) print(" The End")
In the above code, we are printing “nt”, because it will skip letter “I”.
It can be used when a statement is required syntactically but you do not want any code to execute.
for i in "init": if(i == "i"): pass else: print(i)
Continue forces the loop to start the next iteration while pass means “there is no code for execution” and will continue through the remainder of the loop body. The output will be “nt”.