What is the actual benefit of 'continue' statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the actual benefit of 'continue' statement?

Even if we do not use continue..it still continues unless we break it..so how is it helpful..it just seems like increasing the load isn't it?🤔

7th May 2020, 1:46 PM
AMRUTHA B R
3 Answers
+ 3
Run this for i in range(6): if i==3: print("bye") continue elif i==5: print("hi") continue print("hello") print("\n") for i in range(6): if i==3: print("bye") break elif i==5: print("hi") break print("hello")
7th May 2020, 2:02 PM
Abhay
Abhay - avatar
+ 2
continue passes that iteration if condition is met. for (int i=0; i<3; i++) { if (i == 1) continue; cout<< i; } output: 02
7th May 2020, 2:02 PM
Mustafa K.
Mustafa K. - avatar
+ 1
Because there may be some condition in the loop that triggers the continue statement before the loop reaches the end. So the continue would skip the remainder of the loop and start over.
7th May 2020, 2:03 PM
Damyian G
Damyian G - avatar