735 questions
1
vote
2
answers
88
views
Why doesn't sh's continue remember the command's exit status
Why doesn't continue remember the command's exit status in sh?
Given this loop:
#!/bin/sh
for i in 0; do
false || continue
done
echo $?
Output: 0
#!/bin/sh
for i in 0; do
false
done
echo $?
...
-1
votes
2
answers
118
views
Why is the "Continue" statement in Bash not correctly executed inside a "while" loop as part of a "&&" statement?
I face the following problem, which looks like a bug (or maybe am I the bug):
I have a loop:
#!/bin/bash
#
TARGET=/sd/REMOTE_BACKUP
LOGDIR=/sd
DEBUG=:
# Init daily information (reset on each run and ...
1
vote
0
answers
29
views
Python: Quitting a Game At Any Time [duplicate]
I'm creating a multiplication game and am suck on two things. I know they deal with break and continue use.
repeating the same question over again until it is right
providing an option to quit and ...
0
votes
1
answer
42
views
How do I get a try / exception statement to continue? [duplicate]
I need this to rerun the initial inpput question if it gets a value that is unacceptable.
try:
hours = float(input("Please enter your hours worked: "))
if hours < 1 :
...
2
votes
2
answers
140
views
How can i put continue in functions inside the loop in C?
I have a C program with many functions nested, all controlled by a main loop, I need to carry out checks in the functions which, if true, must return the control to the main loop, interrupting that ...
0
votes
3
answers
90
views
Conditional If Statements for data format
I would like to skip an iteration of code if, the data in a cell does not match a string - number - number format. For example, the desired format is Apple-34-56. If the array that I defined has a ...
2
votes
1
answer
157
views
Why does a continue in this ForEach-Object loop cause Powershell to error
When piping the output of a command to a ForEach-Object loop in PowerShell, using a continue statement causes it to error out.
Works as expected:
ipconfig | ForEach-Object {
$_
}
Errors:
ipconfig |...
0
votes
3
answers
1k
views
Continue in a do while loop
I have a do-while loop designed to get a number from user input in the console.
I included error checking and many optional variables to make it versatile (i.e. min and max allowed values, an array of ...
5
votes
3
answers
2k
views
Using continue/return statement inside .ForEach() method - is it better to use foreach ($item in $collection) instead?
It's fairly well documented that foreach processing speed varies depending on the way a foreach loop is carried out (ordered from fastest to slowest):
.ForEach() method
foreach ($item in $collection) ...
1
vote
1
answer
94
views
Continue has no effect in for loop?
I'm a beginner trying to solve this kata:
In this kata you are required to, given a string, replace every letter
with its position in the alphabet.
If anything in the text isn't a letter, ignore it ...
-2
votes
3
answers
222
views
Restart foreach loop if condition is satisfied on last iteration [duplicate]
How do I restart a foreach loop when I reach the last index and some other condition?
The loop needs to run again, instead, it just stops.
foreach ($getUsers as $index => $user) {
$userID = ...
2
votes
1
answer
43
views
Double N to break out asking user if they want to run again and promt again for new input
I am trying to ask a user if they would like to try again a new computation, I used old code from another lab I had but can't seem to get it to adjust proper for this new one.
My problem is that when ...
0
votes
1
answer
55
views
How to fix this loop or function related issue in python?
I am a beginner firstly. I just wrote this simple code but I have one problem. Whenever you guess the wrong number once and try to stop playing, it just doesn't respond to you and continues whatever ...
-7
votes
2
answers
220
views
Continue statement
The continue statement is for skipping the iteration but it doesn’t work as I expect. Here is my code:
int i = 0;
do
{
if(i== 10)continue;
printf("\n This is = %d",i);
i++;
} while ...
-2
votes
2
answers
141
views
Can someone explain the output of this code [closed]
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i<=15;i+=2){
cout<<i<<" ";
...