Issue #15630: Add an example for "continue" statement in the tutorial. Patch by
authorSenthil Kumaran <senthil@uthcode.com>
Sun, 12 Aug 2012 18:58:53 +0000 (11:58 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sun, 12 Aug 2012 18:58:53 +0000 (11:58 -0700)
Daniel Ellis.

Doc/tutorial/controlflow.rst
Misc/NEWS

index 59b7fff196a3a61c11674869f69c0eae7ab325fe..0616613880a8368aa016db54feca8f075b98f491 100644 (file)
@@ -129,9 +129,6 @@ function, see :ref:`tut-loopidioms`.
 The :keyword:`break` statement, like in C, breaks out of the smallest enclosing
 :keyword:`for` or :keyword:`while` loop.
 
-The :keyword:`continue` statement, also borrowed from C, continues with the next
-iteration of the loop.
-
 Loop statements may have an ``else`` clause; it is executed when the loop
 terminates through exhaustion of the list (with :keyword:`for`) or when the
 condition becomes false (with :keyword:`while`), but not when the loop is
@@ -166,6 +163,22 @@ when no exception occurs, and a loop's ``else`` clause runs when no ``break``
 occurs. For more on the :keyword:`try` statement and exceptions, see
 :ref:`tut-handling`.
 
+The :keyword:`continue` statement, also borrowed from C, continues with the next
+iteration of the loop::
+
+    >>> for num in range(2, 10):
+    ...     if x % 2 == 0:
+    ...         print("Found an even number", num)
+    ...         continue
+    ...     print("Found a number", num)
+    Found an even number 2
+    Found a number 3
+    Found an even number 4
+    Found a number 5
+    Found an even number 6
+    Found a number 7
+    Found an even number 8
+    Found a number 9
 
 .. _tut-pass:
 
index baece2edbf961d1d169d0ae6e541c01193a334aa..dfd431ff3b108f099c2a9d1de4cf1286dd7ab5be 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -350,6 +350,9 @@ Build
 Documentation
 -------------
 
+- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
+  Daniel Ellis.
+
 - Issue #13557: Clarify effect of giving two different namespaces to exec or
   execfile().