Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to skip a single loop iteration

I have the following code:

 for k in range(9):
    if k != 3:
        print(k)
    else:
        print(20)
        # i want to skip the next iteration

So I want to get: 0,1,2,20,5,6,7,8, here I skip the fourth iteration. I already try to use the command next(), but it doesn't give what I want