Skip to content

Continue in if statement Python

  • by

Python Continue in if statement used to skip current iteration and instructs a loop to continue to the next iteration. Use continue statements within loops, usually after an if statement.

Continue in if statement Python

Simple example code uses a continue statement in Python to skip over part of a loop when a condition is met. When bb is equal to 2, Skip prints the second name and then continues iterating.

bb = ["Walter", "White", "Jesse", "Pinkman"]

for cast in range(0, len(bb)):
    if cast == 2:
        continue
    else:
        print(bb[cast])

    print("Counter is ",cast)

print("Program Complete")

Output:

Continue in if statement Python

Do comment if you have any doubts or suggestions on this Python continue topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *