Member-only story
Python Programming
How to Use break, continue and pass in Python Programming
Learn how, when and why to use break, continue and pass in Python
Python — being flexible — is the best solution to automate and to do repetitive tasks in efficient way!
In Python (and other programming languages also), the concept of loops helps to iterate over a list, tuple, string, dictionary, and a set.
Loops iterate over a block of code until the test expression is false, but sometimes we wish to terminate the current iteration or even the whole loop without checking test expression.
This can be achieved using few keywords which can be used to alter the flow or execution of the loops. And in Python those keywords are — break, continue, pass. 💡
And it is important to know when and how to use these keywords to control the flow of your loop correctly!
Therefore, in this article, I am discussing (with examples) when-why-how of break, continue and pass in Python.
The concept behind these keywords is same irrespective of the programming language!
Let’s get started!