Question
Asked By – JohnG
The definition of the continue
statement is:
The
continue
statement continues with the next iteration of the loop.
I can’t find any good examples of code.
Could someone suggest some simple cases where continue
is necessary?
Now we will see solution for issue: Example use of “continue” statement in Python?
Answer
Here’s a simple example:
for letter in 'Django':
if letter == 'D':
continue
print("Current Letter: " + letter)
Output will be:
Current Letter: j
Current Letter: a
Current Letter: n
Current Letter: g
Current Letter: o
It skips the rest of the current iteration (here: print
) and continues to the next iteration of the loop.
This question is answered By – Snehal Parmar
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0