Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ef9caa

Browse files
committed
Issue #15630: Add an example for "continue" statement in the tutorial. Patch by
Daniel Ellis.
1 parent c7b0e21 commit 1ef9caa

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

Doc/tutorial/controlflow.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,6 @@ Later we will see more functions that return iterables and take iterables as arg
157157
The :keyword:`break` statement, like in C, breaks out of the smallest enclosing
158158
:keyword:`for` or :keyword:`while` loop.
159159

160-
The :keyword:`continue` statement, also borrowed from C, continues with the next
161-
iteration of the loop.
162-
163160
Loop statements may have an ``else`` clause; it is executed when the loop
164161
terminates through exhaustion of the list (with :keyword:`for`) or when the
165162
condition becomes false (with :keyword:`while`), but not when the loop is
@@ -194,6 +191,22 @@ when no exception occurs, and a loop's ``else`` clause runs when no ``break``
194191
occurs. For more on the :keyword:`try` statement and exceptions, see
195192
:ref:`tut-handling`.
196193

194+
The :keyword:`continue` statement, also borrowed from C, continues with the next
195+
iteration of the loop::
196+
197+
>>> for num in range(2, 10):
198+
... if x % 2 == 0:
199+
... print("Found an even number", num)
200+
... continue
201+
... print("Found a number", num)
202+
Found an even number 2
203+
Found a number 3
204+
Found an even number 4
205+
Found a number 5
206+
Found an even number 6
207+
Found a number 7
208+
Found an even number 8
209+
Found a number 9
197210

198211
.. _tut-pass:
199212

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ Build
468468
Documentation
469469
-------------
470470

471+
- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
472+
Daniel Ellis.
473+
471474
- Issue #15444: Use proper spelling for non-ASCII contributor names. Patch
472475
by Serhiy Storchaka.
473476

0 commit comments

Comments
 (0)