mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	Issue #15630: Add an example for "continue" statement in the tutorial. Patch by
Daniel Ellis.
This commit is contained in:
		
							parent
							
								
									c7b0e217e2
								
							
						
					
					
						commit
						1ef9caa2a1
					
				
					 2 changed files with 19 additions and 3 deletions
				
			
		| 
						 | 
					@ -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
 | 
					The :keyword:`break` statement, like in C, breaks out of the smallest enclosing
 | 
				
			||||||
:keyword:`for` or :keyword:`while` loop.
 | 
					: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
 | 
					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
 | 
					terminates through exhaustion of the list (with :keyword:`for`) or when the
 | 
				
			||||||
condition becomes false (with :keyword:`while`), but not when the loop is
 | 
					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
 | 
					occurs. For more on the :keyword:`try` statement and exceptions, see
 | 
				
			||||||
:ref:`tut-handling`.
 | 
					: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:
 | 
					.. _tut-pass:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -468,6 +468,9 @@ Build
 | 
				
			||||||
Documentation
 | 
					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
 | 
					- Issue #15444: Use proper spelling for non-ASCII contributor names.  Patch
 | 
				
			||||||
  by Serhiy Storchaka.
 | 
					  by Serhiy Storchaka.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue