How to use goto in Python
A goto statement is used to perform a jump from one location to another. It is a piece of code where we can change the flow of execution from the point where goto statement is defined to one that is marked as the destination
comefrom is another statement that works similar to the goto function. Both goto and comefrom statements provide flexibility and scalability to the Python programs. This enables to control the mechanism of program flow.
Below is the code to import both comefrom and goto statements in the main library.
From goto import goto, comefrom, label
Let’s look at an example:
from goto import goto, label for x in range(1, 10): for y in range(1, 20): for z in range(1, 30): print (x,y,z) if z == 3: goto .end label .end print "Finished"
Please login to comment
View all comments