summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2012-08-12 19:01:47 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2012-08-12 19:01:47 (GMT)
commit1ef9caa2a19c6e4675f853be38f7db341e0ba3ec (patch)
treef2514852cb00977a00aad0b1134da86a0b035bc5
parentc7b0e217e2ee000138ca5e7d6d08502c4995cf20 (diff)
downloadcpython-1ef9caa2a19c6e4675f853be38f7db341e0ba3ec.zip
cpython-1ef9caa2a19c6e4675f853be38f7db341e0ba3ec.tar.gz
cpython-1ef9caa2a19c6e4675f853be38f7db341e0ba3ec.tar.bz2
Issue #15630: Add an example for "continue" statement in the tutorial. Patch by
Daniel Ellis.
-rw-r--r--Doc/tutorial/controlflow.rst19
-rw-r--r--Misc/NEWS3
2 files changed, 19 insertions, 3 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst
index 902f2bd..3c0f88e 100644
--- a/Doc/tutorial/controlflow.rst
+++ b/Doc/tutorial/controlflow.rst
@@ -157,9 +157,6 @@ Later we will see more functions that return iterables and take iterables as arg
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
@@ -194,6 +191,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:
diff --git a/Misc/NEWS b/Misc/NEWS
index 409d3ca..e0559c5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -468,6 +468,9 @@ Build
Documentation
-------------
+- Issue #15630: Add an example for "continue" stmt in the tutorial. Patch by
+ Daniel Ellis.
+
- Issue #15444: Use proper spelling for non-ASCII contributor names. Patch
by Serhiy Storchaka.