Python continue Statement
Python continue statements to jump out of this cycle, and break out of the cycle.
continue statement is used to tell Python to skip the rest of the statements of the current cycle, and then continue with the next cycle.
continue statement is used in while and for loops.
Python language continue statement syntax 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!"
The results of the above examples:
当前字母 : P 当前字母 : y 当前字母 : t 当前字母 : o 当前字母 : n 当前变量值 : 9 当前变量值 : 8 当前变量值 : 7 当前变量值 : 6 当前变量值 : 4 当前变量值 : 3 当前变量值 : 2 当前变量值 : 1 当前变量值 : 0 Good bye!