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?🤔
4 Respuestas
+ 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")
+ 2
continue passes that iteration if condition is met.
for (int i=0; i<3; i++)
{
if (i == 1)
continue;
cout<< i;
}
output:
02
+ 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.