Related Ads Link

Difference Between Python Pass vs Continue Statements

Difference Between Python Pass vs Continue Statements

Python Pass vs Continue Statements: Hello Everyone, Thanks for Visiting Codinglio. This is the Right Place for a Programming and Coding Lovers. here you Learn Coding with Professionals. We have already Created Programming Community For those who wanna rise a Question and get answers. Today we are gonna talk about Two basic Python Statements i.e Pass and Continue. If you find these somehow useful and informational, hit the share button. So, Lets directly jump over the topic:

Are The Python Pass and Continue Statement Different?

Hell Yeah.! These are Totally Different by Working. These are used as per the various jobs. You need to learn where both of them used. We will talk about both one by one. First, we are gonna talk about the First Statement which is, Pass Statement.

What Does Python Pass Statement Do?

Python Pass Statement simply does Nothing.! sounds weird right? Well yes. Pass statement tells the Conditional Expression that there is No Statement here, so it skips the Conditional Expression and Moves forward. We will learn it by a Simple Example after explaining the Second Statement. So here this second one is;

What Does Python Continue Statement Do?

What This Python Continue Statement Does is, It actually forces the Loop to start at the next iteration. Continue Statement Provide a job to the interpreter to restart the expression. While both of these statements are placed at the last of the loop, still the do various jobs. here is an example that will help you understand this logic very easily

Differentiate between Pass and Continue Statements:

Here is the simple example that will make you understand this really simple logic very fast. So let’s head forward it;

for element in the_list:
if not element:
pass
print 1 # will print after pass

for element in the_list:
if not element:
continue
print 1 # will not print after continue

Look:

In the first for loop, we just provided a Pass Statement, what it does here, will print “1” after the Pass Statement, because pass will force interpreter to get out from the for loop and will continue to the print function. on another hand where we just used continue will not print “1” after the Statement, because the control will go to the head again and the iteration will restart.

Conclusion:

If you have learned something from here, then support us to grow by sharing this post to your social media platforms which we have provided below. This post can be helpful for others too. keep Visiting Cheers.!!

 



A Programmer by Passion and a Passionate Blogger by Heart <3 . CodingLio was my Dream Idea, I wanted To Create a Medium where, Geeks can actually Learn Something.


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: