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
-4
votes
4 answers

Continue doesn't seem to work in this simple Python function

The function is supposed to take a string as its input and return (if all members of the string are digits) and integer version of that string. The string provided in this example is a 3 digit number. the function's for loop seems to only return the…
-4
votes
4 answers

Why does 'continue' and 'break' give the same results?

In my code, the keywords 'continue' and 'break' give the same output. What is the reason? First code: x = 0 while x < 5: if x == 2: break print(x) x += 1 Output: 0 1 Second code: x = 0 while x < 5: …
Röyal
  • 87
  • 9
-4
votes
2 answers

Java - Do you want to continue?(Y/N)

I want to write a simple loop for the program to go back and restart it again. Just a simple 1 question program. Then the system ask if the user want to do it again. If the user inputs Y ... the program will loop it back to the beginning and run the…
DCN
  • 3
  • 1
  • 1
  • 4
-4
votes
3 answers

not restarting for program and input integer not working

I'm trying to develop a program wherein at the finish of the game the user will input "Yes" to make the game restart, while if the user inputed "Not" the game will end. For my tries, I can't seem to figure out how to make the program work. I'm quite…
Bear
  • 11
  • 2
-4
votes
1 answer

continue not working? [c++]

Hi guys I've run into a problem,for some reason a blank string is being printed or you could also say nothing is being printed when I try to print out the string,this only occurs when I include a capital letter in the string such as acB if I type…
irishmaniac
  • 101
  • 1
  • 12
-4
votes
1 answer

Using 'continue' with modulo

I'm kinda new at c# programming so take it easy on me. I couldn't find the answer to my (most likely) simple an stupid question (there's no stupid questions!!) so I post here. I need to write a program which shows numbers from 1 to 10 that aren't…
-4
votes
3 answers

Can anyone explain me the java continue statement execution in the following code?

I have a program like this: public class OCAJP { public static void main(String[] args) { int i=0; for(;i<2;i=i+5) { if(i<5) { continue; } System.out.print(i); } …
Vignan Sankati
  • 380
  • 5
  • 15
-4
votes
2 answers

How do I use the python continue keyword as a string literal in a python script?

I'm writing a python script wherein I need to use the continue word. I know that it is a python keyword. So how should I write my script so that python will not complain that I am using a keyword as a string literal. Thanks in advance for your time.
Hamza Ahmed
  • 1,571
  • 4
  • 18
  • 35
-4
votes
1 answer

Continue isnt working properly

I do need help in solving my code. Below python code 'continue' is not working properly dicemp = {'12345':''} while(1): choice = int(input("Please enter your choice\n")) if (choice == 1): empno = input("Enter employee number: ") …
-4
votes
1 answer

C# Continue execution of program after Exception is thrown

How can I make the program continue its execution even if it crashes(Throws an exception).My current program works just fine if I manually press continue after the execution is thrown,so I want to make it continue the execution each time an…
Cata
  • 101
  • 1
  • 12
-4
votes
1 answer

is it possible that the code skip continue?

Is there any case that the program will skip continue? This is the code: while(/*something*/){ if(/*something*/){ while(true) { //do something } …
onlyforthis
  • 444
  • 1
  • 5
  • 21
-4
votes
1 answer

continue instead of return inside a function in C++`

Does it make sense to use continue instead of return, while completing a function in C++? void function() { //do something; continue; //instead of return }
SKPS
  • 5,433
  • 5
  • 29
  • 63
-5
votes
3 answers

For cicle: increment and decrement of variables

i wrote a code structured like this int function(){ int i, counter = 0; for(i=INTEGER; i>0; ++counter, --i){ if(condition){ //do stuff i+=2; continue; …
wing
  • 57
  • 1
  • 9
-5
votes
2 answers

Moving on deep function

I have a short question: How can I move from A to B in this code: for(var i=0;i
Adacho
  • 99
  • 4
  • 13
-5
votes
7 answers

Is the code after 'break' executed?

for (...) for (...) { break; break; // 1 } Will the code at (1) execute? There could also be there continue or anything else. I know I could just check in my debugger but I wanna know what C++ standard says about it as…
NPS
  • 6,003
  • 11
  • 53
  • 90
1 2 3
48
49