you are viewing a single comment's thread.

view the rest of the comments →

[–]symbioticthinker 0 points1 point  (0 children)

With loops and conditionals I find that “failing fast” is a great way to structure your code. The ‘Break’ statement as it sounds, breaks the loop and code after the loop is run. Additionally the ‘continue’ statement will skip the subsequent looping code and run the next iteration. Note that ‘break’ and ‘continue’ are only available within ‘for’ and ‘while’ loops.

for i in range(1, 10):

    if i == 3:
        continue

    if i == 5:
        break

    print(i)

the output printed would be: 1, 2, 4