python | continue statement

Introduction: In Python, the continue statement is used to tell Python to skip the remaining statements of the current loop, and then continue with the next cycle of the loop (while break is to jump out of the entire loop).

Author: Han Xinzi
@ ShowMeAI Tutorial address : http://www.showmeai.tech/tutorials/56This
article address : http://www.showmeai.tech/article-detail/74Disclaimer
: All rights reserved, please contact the platform and Author and credit

Python-continue statement
The Python continue statement is used to tell Python to skip the remaining statements of the current loop and continue with the next loop (while break is to jump out of the entire loop).
The continue statement is used in while and for loops.
The syntax of the continue statement in Python language is as follows:
continue
flow chart:

Here is the code sample (the code can be run in an online python3 environment ):
for letter in ' ItIsShowMeAI ' : # first instance
if letter == 'h' :
continue
print( 'Current letter:' , letter)

var = 10 # second instance
while var > 0 :
var = var -1
if var == 5 :
continue
print( 'Current variable value:' , var)
print( "Complete!" )
The execution result of the above example:
Current letter: I
Current letter: t
Current letter: I
Current letter: s
Current letter: S
Current letter: o
Current letter: w
Current letter: M
Current letter: e
Current letter : A
Current letter: I
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
Finish!

Copyright statement: The content of this article is contributed by Alibaba Cloud's real-name registered users. The copyright belongs to the original author. The Alibaba Cloud developer community does not own the copyright and does not assume the corresponding legal responsibility. For specific rules, please refer to the " Alibaba Cloud Developer Community User Service Agreement " and " Alibaba Cloud Developer Community Intellectual Property Protection Guidelines ". If you find any content suspected of plagiarism in this community, fill out the infringement complaint form to report it. Once verified, this community will delete the allegedly infringing content immediately.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00