Home > Article > Backend Development > What does the Python continue statement do? Detailed explanation of the usage of Python continue statement
This article mainly introduces python statements. The Python continue statement jumps out of this loop, and 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 then continue to the next round of the loop. continue statement is used in while and for loops.
The Python language continue statement syntax format is as follows:
continue
Flow chart:
Example:
#!/usr/bin/python # -*- coding: UTF-8 -*- for letter in 'Python': # 第一个实例 if letter == 'h': continue print '当前字母 :', letter var = 10 # 第二个实例 while var > 0: var = var -1 if var == 5: continue print '当前变量值 :', var print "Good bye!"
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!
Knowledge points related to this article:
I hope this article can help you in your work
The above is the detailed content of What does the Python continue statement do? Detailed explanation of the usage of Python continue statement. For more information, please follow other related articles on the PHP Chinese website!