Continue Statement in Python

pythonwithyp Continue Statement in Python
Continue Statement in Python

Continue Statement in Python

A continue statement terminates the current iteration of a loop. Loop control pass from the continue statement and execute the statement 

A continue statement is used in both loops for and while . 


Continue statement in for loop

Example

    for val in "python":

        if val == "h":

            continue

        print(val)

    print("End of Loop")


Output

    p

    y

    t

    o

    n

    End of Loop


Continue Statement in While Loop

Example

    var = 1

    while var <10:

        var+=1

        if var == 5:

            continue    

        print(var)

    

Output

    2

    3

    4

    6

    7

    8

    9

    10


Post a Comment (0)
Previous Post Next Post