Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k points)

Is there any significant difference between the two python keywords continue and pass like in the examples

for element in some_list: 

if not element:

pass

and

for element in some_list:

if not element:

continue

I should be aware of?

1 Answer

0 votes
by (106k points)

Yes, there is a difference. continue forces the loop to start at the next iteration while pass means "there is no code to execute here" and will continue through the remainder or the loop body.

You can run the below-mentioned code and see the difference:-

for element in some_list:

if not element:

pass

print 1

for element in some_list:

if not element:

continue

print 1 

Related questions

0 votes
1 answer
asked Oct 4, 2019 in Python by Tech4ever (20.3k points)
0 votes
1 answer
asked Jul 30, 2019 in Java by Krishna (2.6k points)
0 votes
1 answer
asked Jul 9, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer

Browse Categories

...