Home > Backend Development > Python Tutorial > Python continue statement

Python continue statement

高洛峰
Release: 2016-11-23 10:45:03
Original
1205 people have browsed it

Python continue statement jumps out of this loop, while break jumps out of the entire loop. The

continue statement is used to tell Python to skip the remaining statements of the current loop and continue with the next round of loops.

continue statement is used in while and for loops.

Python language continue statement syntax is as follows:

continue

Flowchart: Python continue statement

Example:

#!/usr/bin/python
 
for letter in 'Python':     # First Example
   if letter == 'h':
      continue
   print 'Current Letter :', letter
 
var = 10                    # Second Example
while var > 0:             
   var = var -1
   if var == 5:
      continue
   print 'Current variable value :', var
print "Good bye!"
Copy after login

Execution result of the above example:

Current Letter : P

Current Letter : y

Current Letter : t

Current Letter : o

Current Letter : n

Current variable value : 9

Current variable value : 8

Current variable value : 7

Current variable value : 6

Current variable value : 4

Current variable value : 3

Current variable value : 2

Current variable value : 1

Current variable value : 0

Good bye!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template