Leo Umesh avatar

CONTINUE STATEMENT IN PYTHON

leoumesh

Published: 06 Aug 2020 › Updated: 06 Aug 2020CONTINUE STATEMENT IN PYTHON

CONTINUE STATEMENT IN PYTHON

This is a simple basic conceptual program on how continue statement works in python. In the code below we can see that from 1 to 50, the numbers that are divisible by both 4 and 5 (i.e. 20 and 40) are not printed. The rest numbers are printed. Remember for the 'and' logical operator both statements must be true. The continue statement is used to skip the rest of the code inside the loop and is used to go back to beginning of the loop to begin the next iteration. That meant to say that continue won't execute the statement whose condition is true.

for i in range(1,50):
    if i%4==0 and i%5==0:
        continue
        
    print(i) 

If you run the above code, you can see the following output:

Screenshot_1.png

You can run this code online here.

Leave CONTINUE STATEMENT IN PYTHON to:

Written by

I am just a passionate blogger.

Read more #code posts


Best Posts From Leo Umesh

We have not curated any of leoumesh's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Leo Umesh