alternative
  • Home (current)
  • About
  • Tutorial
    Technologies
    SQL -Structured Query Language
    Python
    Ethical Hacking
    Java
    .net Framework
    Placement Preparation
    Quantitative Aptitude
    View All Tutorial
  • Quiz
    SQL -Structured Query Language
    Quantitative Aptitude
    Java
    View All Quiz Course
  • Q & A
    Quantitative Aptitude
    Java
    View All Q & A course
  • Programs
  • Articles
    Artificial Intelligence & Machine Learning Project
    How to publish your local website on github pages with a custom domain name?
    How to download and install Xampp on Window Operating System ?
    How To Download And Install MySql Workbench
    How to install Pycharm ?
    How to install Python ?
    How to download and install Visual Studio IDE taking an example of C# (C Sharp)
    View All Post
  • Tools
    Program Compiler
    Sql Compiler
    Replace Multiple Text
    Meta Data From Multiple Url
  • Contact
  • User
    Login
    Register

Python - Decision control and looping statement - Continue Statement Tutorial

Continue statement is used to stop the current iteration and continue with the next iteration. It is used to skip the current iteration.

Continue statement can be performed in any loop( for , while)

Syntax-

continue;

Example-

# List of number
number = [4, 1, 2, 27, 25, 73]
# iterate over the list of number
for val in number:
    if(val==27):
        continue;
    print(val)

 

Output-

4
1
2
25
73

In above program, if val is 27 it will skip the current iteration and will print the next number i.e [25, 73] .

While in break statement, it the val = 27 then it will get stop and will not print next number i.e [25, 73] .

So, for break statement output will be –

4
1
2

 

Continue statement in while loop

Example-

i=1
while i <= 6:
    i=i+1
    if(i==3):
        continue
    print(i)

 

Output-

2
4
5
6
7

 

Nested Loop

Without Continue Statement-

# a for loop will executed 3 time i.e from 1 to 3
# b for loop will executed 3 time i.e from 2 to 4
for a in range(1,4):
    for b in range(2,5):
        print("a="+str(a)+" b="+str(b))

 

Output-

a=1 b=2
a=1 b=3
a=1 b=4
a=2 b=2
a=2 b=3
a=2 b=4
a=3 b=2
a=3 b=3
a=3 b=4

 

With Continue Statement-

# a for loop will executed 3 time i.e from 1 to 3
# b for loop will executed 3 time i.e from 2 to 4
for a in range(1,4):
    for b in range(2,5):
        if(b==3):
            continue;
        print("a="+str(a)+" b="+str(b))

 

Output-

a=1 b=2
a=1 b=4
a=2 b=2
a=2 b=4
a=3 b=2
a=3 b=4

In the above program, whenever in the inner loop b become 3, continue statement will skip the current iteration, and continue with the next iteration.

 

.

 

 

 

 

 

Python

Python

  • Introduction
  • Installation and running a first python program
    • How to install Python ?
    • Running 1st Hello World Python Program
    • How to install Pycharm ?
  • Things to know before proceed
    • Escape Characters/Special Characters
    • Syntax ( Indentation, Comments )
    • Variable
    • Datatype
    • Keyword
    • Literals
    • Operator
    • Precedence & Associativity Of Operator
    • Identifiers
    • Ascii, Binary, Octal, Hexadecimal
    • TypeCasting
    • Input, Output Function and Formatting
  • Decision control and looping statement
    • if-else
    • for loop
    • While loop
    • Break Statement
    • Continue Statement
    • Pass Statement
  • Datatype
    • Number
    • List
    • Tuple
    • Dictionary
    • String
    • Set
    • None & Boolean
  • String Method
    • capitalize()
    • upper()
    • lower()
    • swapcase()
    • casefold()
    • count()
    • center()
    • endswith()
    • split()
    • rsplit()
    • title()
    • strip()
    • lstrip()
    • rstrip()
    • find()
    • index()
    • format()
    • encode()
    • expandtabs()
    • format_map()
    • join()
    • ljust()
    • rjust()
    • maketrans()
    • partition()
    • rpartition()
    • translate()
    • splitlines()
    • zfill()
    • isalpha()
    • isalnum()
    • isdecimal()
    • isdigit()
    • isidentifier()
    • islower()
    • isupper()
    • isnumeric()
    • isprintable()
    • isspace()
    • istitle()
  • Python Function
    • Introduction
  • Lambda Function
    • Lambda Function
  • Python Advanced
    • Iterators
    • Module
    • File Handling
    • Exceptional Handling
    • RegEx - Regular Expression
    • Numpy
    • Pandas

About Fresherbell

Best learning portal that provides you great learning experience of various technologies with modern compilation tools and technique

Important Links

Don't hesitate to give us a call or send us a contact form message

Terms & Conditions
Privacy Policy
Contact Us

Social Media

© Untitled. All rights reserved. Demo Images: Unsplash. Design: HTML5 UP.