Is there any significant difference between the two python keywords continue
and pass
like in the examples
for element in some_list
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.
Run these and see the difference:
for element in some_list:
if not element:
pass
print 1 # will print after pass
for element in some_list:
if not element:
continue
print 1 # will not print after continue