Continue means "jump to start of loop", ignoring rest of the statements in the loop
Code | Output |
for r in [1,2,3]: print(r) continue print(r,"\tagain") | 1 2 3 |
for r in [1,2,3]: print(r) pass print(r,"again") | 1 (1, 'again') 2 (2, 'again') 3 (3, 'again') |
for r in [1,2,3]: if r%2!=0: print(r) else: pass | 1 3 |
for r in [1,2,3]: if r%2==0: continue print(r) Bad coding practice according to me but nevertheless this is possible. | 1 3 |
No comments:
Post a Comment