Python continue statement
Python continue statement
The Python continue statement jumps out of this loop, while the break jumps out of the entire loop.
The continue statement is used to tell Python to skip the remaining statement of the current loop and then continue the next loop.
The continue statement is used in the while and for loops.
The syntax format of the Python continue statement is as follows:
continue
Flowchart:
Instance:
#! /Usr/bin/python #-*-coding: UTF-8-*-for letter in 'python': # first instance if letter = 'H ': continue print 'current letter: ', lettervar = 10 # The Second Instance while var> 0: var = var-1 if var = 5: continue print 'current variable value :', varprint "Good bye! "
Execution result of the above instance:
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.
Python pass statement
Python pass is a null statement to maintain the integrity of the program structure.
Passass does not do anything. It is generally used as a placeholder statement.
The syntax format of the pass statement in Python is as follows:
pass
Instance:
#! /Usr/bin/python #-*-coding: UTF-8-*-# output each letter of Python in 'python': if letter = 'H ': pass print 'this is the pass block 'print 'current letter:', letterprint "Good bye! "
Execution result of the above instance:
Current letter: P current letter: y current letter: t this is the pass block current letter: h current letter: o current letter: nGood bye!
!