Python break & continue Statement

Basically break statement is considered as transfer statement. When the break statement executes based on a condition inside a loop, then the loop is terminated.

Let’s see the following example; here loop is terminating when x==”PHP”

course=["Java","Oracle","PHP","Android","Python"]
for x in course:
    print(x)
    if(x=="PHP"):
        break

Output


Like break statement, the continue statement is another transfer statement. When the continue statement executes based on a condition inside a loop, then some portion of the loop is skipped.

Using continue statement we can stop the current iteration of the loop, and continue with the next:

Let’s see an example;
course=["Java","Oracle","PHP","Android","Python"]
for x in course:
    if(x=="PHP"):
      continue
print(x)

Output


About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext