Python while loop

i, j, k = 0, 0, 0

print('Traditional while loop with N steps:')
while i < 5:
    print(i)
    i += 1

print('Break the while loop:')
while j < 5:
    if j == 3:
        print('Skipped 3 and break the loop')
        break
    print(j)
    j += 1
    
print('Skip the step and pass to the next step of the while loop:')
while k < 5:
    if k == 3:
        print('Skipped 3 and pass to the next step of the loop')
        pass
    print(k)
    k += 1

Leave a Comment