WEB DEVELOPER SITE
PHP7
 

Python continue statement


terminated the loop current iteration, and continue with the start immediately

Syntax

continue

Example

#!/usr/bin/python

for letter in 'welookups':     # First Example
   if letter == 'O':
      break
   print 'Current Letter :', letter
  
var = 10                    # Second Example
while var > 0:              
   print 'Current variable value :', var
   var = var -1
   if var == 5:
      break

print "Good bye!"
When the above code is executed, it produces the following result −
$python main.py
Current Letter : w
Current Letter : e
Current Letter : l
Current Letter : o
Current Letter : o
Current Letter : k
Current Letter : u
Current Letter : p
Current Letter : s
Current variable value : 10
Current variable value : 9
Current variable value : 8
Current variable value : 7
Current variable value : 6
Good bye!