Questions tagged [continue]

A language construct typically used to bypass the rest of a loop and return to the beginning for the next iteration.

Using continue will go back to the first line of the loop, in this example when i is 2 or 3 the program will immediately go back to the first line: for i in range(1, 6) before the current iteration has finished

Example (Python):

for i in range(1, 6):
    print(i)
    if i == 2 or i == 3:
        continue
    print("do stuff")
print("after the loop")

Output:

1
do stuff
2
3
4
do stuff
5
do stuff
after the loop

Also see .

724 questions
3
votes
2 answers

Labeled-break/continue in C# or Fortran 95 loops?

I've been tasked in a homework assignment with converting a loop in C# into Fortran 95. outerLoop: for(row = 0; row < numRows; rows++){ for(col = 0; col < numCols; col++){ if(mat[row][col] == 0) continue outerLoop; sum +=…
Rxanadu
  • 89
  • 2
  • 9
2
votes
4 answers

how to save and retrive data from the last run of an android application?

I have to create a small android application for my college course work which presents 10 maths problems and take answers from users to calculate the score. The program is supposed to have a main screen with "new game" button and a "continue"…
Maduranga E
  • 1,679
  • 5
  • 23
  • 37
2
votes
2 answers

how to program wait and continue in this bash script

I have two shell scripts say A and B. I need to run A in the background and run B in the foreground till A finishes its execution in the background. I need to repeat this process for couple of runs, hence once A finishes, I need to suspend current…
marc
  • 949
  • 14
  • 33
2
votes
5 answers

Linq to sql - delete and if fails continue

If I have a table like: StudentId | ... | SchoolId ___________|_____|__________ 1 | ... | SchoolA 2 | ... | SchoolA 3 | ... | SchoolB ... And I want to delete a list of schools, from schoolA to schoolZ (using…
DJPB
  • 5,429
  • 8
  • 30
  • 44
2
votes
2 answers

Continue activity after screen orientation change - Android

i currently have a class that'll play audio Files, however if i tilt my screen to horizontal or portrait, it just restarts. How can i make my app continue from where it left off after i tilt my screen? Note that i do not want my app to be fixed in…
Sith
  • 105
  • 1
  • 4
  • 11
2
votes
1 answer

Is there a way to have a function invoke 'continue' affecting a loop in its caller?

I am trying to refactor a code that consists of nested loops. For a similar repetitive code snippet, I am trying to write a function which consists of a 'continue' within. The loop is very long and I just want to include the if statement in the…
Gokarna
  • 23
  • 3
2
votes
2 answers

How to ignore/continue if TD does not contain an image?

I need to continue; if TD does not contain an image. I tried this: if(!$image){continue;} but that did not work.
al-dr
  • 147
  • 1
  • 3
  • 10
2
votes
5 answers

Is it possible to skip a fixed number of iterations in a loop in Python?

Introduction: So I know that there is already a question (Skip multiple iterations in loop) similar to mine with a really good answer, but there are still some open questions for me: Question 1: Is there any way of doing it without an iterator? I…
Pixelbog
  • 236
  • 1
  • 8
2
votes
1 answer

Powershell not continuing/not catching/not trapping

I am trying to speed up a program i've written to make copies of images in a new folder. I've gotten it to work when they all happen to have a standardized name, such as EA101, EA102, ect. I'm fairly new to Powershell but am familiar with…
Zachary
  • 21
  • 2
2
votes
1 answer

I can´t print out 0 . Can someone tell me why?

I can´t print out 0 . Can someone tell me why? import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); System.out.print("Number: "); int number =…
Igor Gryp
  • 67
  • 5
2
votes
2 answers

Lua goto statement to simulate continue raised error

Generally, my goal is to simulate the continue statement, which doesn't exist in Lua. I have read some thread about using goto to do this. I tried: for i=0, 9, 1 do if i<5 then goto skip end print(i) ::skip:: end It raised "lua:…
RazorVE
  • 57
  • 7
2
votes
2 answers

Explain about java continue & break the following code briefly

Explain briefly the function of the code below. About continue & break operations. I can't understand properly label1, label2.....Please describe code functions (The label is basically used in nested loops  But note that they are used here to…
2
votes
1 answer

Python 3 Use case for continue instead of not (!=)

So I'm learning Python finally and I've just learned about skipping to the next iteration of a loop using continue. Now my question is, what would be a real world use case for continue instead of not or != ? Consider the three pieces of simple code…
2
votes
1 answer

PHP does scope change for loops and switch in included files

If, within a for loop, there is an included file, and in that included file, there's another for loop, a continue 2 doesn't work is this by design? or is this a bug? AM totally at a loss info below contents of file temp_outer_loop.php
Rajan
  • 137
  • 9
2
votes
2 answers

How to continue a while loop in bash if certain message printed by program?

I'm running a bash script using some software which follows the basic pattern below. while read sample; do software ${sample} > output.txt done