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

Skip to content

Commit b2d8502

Browse files
committed
merge from 3.2
Issue #15630: Add an example for "continue" statement in the tutorial. Patch by Daniel Ellis.
2 parents 2e64a0b + 1ef9caa commit b2d8502

2 files changed

Lines changed: 32 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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ Core and Builtins
1313
Library
1414
-------
1515

16+
C API
17+
-----
18+
19+
Extension Modules
20+
-----------------
21+
22+
Tools/Demos
23+
-----------
24+
25+
Documentation
26+
-------------
27+
28+
- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
29+
Daniel Ellis.
30+
31+
1632

1733
What's New in Python 3.3.0 Beta 2?
1834
==================================

0 commit comments

Comments
 (0)