2,613 questions
-2
votes
2
answers
130
views
My while loop is looping despite reaching the break. It loops once then goes on with the rest as normal. I am at my wits end [closed]
it's not breaking and I don't know why
This is the problem section of the code. It is working fine, the try except is fine, and the check if not in range's break is working fine. But not the second ...
-4
votes
4
answers
180
views
"break" function doesn't work correct within "while" cycle
Task: to make console to display a message "Happy birthday!". Number of messages equals the number which user inputs to console.
Condition: program should break the cycle, when number of ...
0
votes
0
answers
38
views
Exiting properly from multiple if/then statements, AND comparing the length of a variable
Good day everyone. I am writing a script which will parse a flat file with all the information I need, and if a certain variable is too long, or greater than some length, I need to break out of that ...
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 ...
1
vote
3
answers
161
views
Switch inside while and break statement
Suppose I have a piece of C code
while(1)
{
switch(a){
case 1:
if(b==1)
break;//first break
break;//second break
}
}
...
0
votes
1
answer
52
views
How can I make the nested while-loops end if the board is filled?
I've tried quite a few solutions so my program is a bit jumbled, but I still can't figure out a way to check for "_" and end the game if there are none left. I'd actually rather have them ...
-3
votes
3
answers
122
views
C# How to use this while loop? [closed]
I'm a beginner to programming and have this task I want to complete.
Task at hand:
Write a program where the user is allowed to enter their name, then (in a while loop) the program prompts the user to ...
-4
votes
1
answer
83
views
I can't stop my program in Python, even with Ctrl-C
month =
{"January" : "01",
"February" : "02" ,
"March" : "03",
"April" : "04",
"May"...
0
votes
1
answer
67
views
What to add/change in script so after selecting something from menu it returns to menu and not exits
I found this bash script to make a menu and it is wonderful except I would like it to stay in the script, return back to the menu after something has been selected unless the last option exit has been ...
0
votes
0
answers
55
views
while (true) loop executing once more after break statement when reading file [duplicate]
I'm trying to read a file that has this format:
1
2
3
4
I'm trying to store these values into an array using a while loop:
ifstream myfile("file.dat");
int n, i;
int myarray[30];
if (!...
-2
votes
1
answer
69
views
I can't break a while loop with user input
I'm learning to use functions in while loops. My goal is to ask the user for input inside the while loop and use the input as an argument in the function. But if input at any moment is == 'q', the ...
-1
votes
1
answer
70
views
How can I close a loop without exiting the 'game' [closed]
I'm looking for a little help to clean up my code for a class assignment. The code itsself works as intended, but I'm looking for a way to show the ending message without closing out of the program or ...
0
votes
1
answer
82
views
Immediate break after input using switch or if
I am learning C right now and im at the very beginning.
Here's my code:
#include <stdio.h>
int main (){
char operator;
double num1;
double num2;
double result;
printf("\n Enter an ...
-1
votes
1
answer
45
views
In a three nested for loop with labeled break, why is the output the same when the labeled break is positioned in the inner and middle loop?
Why is the output exactly the same when the labeled break is positioned before the start of the middle and inner loop?
Example code 1 - When break point is positioned at the start of the inner loop
...
0
votes
1
answer
41
views
How to make a loop, repeat a loop again for my nims
# importing random module, for random choices
import random
# print_move function to display CPU and players current move
def print_move(current_player, row, stick_quantity):
current_player = ...
2
votes
1
answer
114
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 |...
3
votes
1
answer
308
views
How exit a BEGIN loop in Forth?
In many languages there is the BREAK statement, which allows you to escape an iterative cycle.
I can't find a word to escape a BEGIN-AGAIN or BEGIN-UNTIL cycle in Forth
I want to implement this code
...
-1
votes
1
answer
36
views
Questions about data output in Python and Excel [duplicate]
For Excel use, I want to create a code that represents A1, A2,...D1, ... AB1, AB2, ...
field = [A, B, C, ..., AA, AB, ..., YZ, ZZ]
data = [[1, 2,3,4,5], [2, 3,4,5,6], [3, 5,4,3,5], [4, 5,6,7,7],...] #[...
1
vote
1
answer
65
views
Switch executes default even with break in every case
So i'm trying to break out of the switch and while statements using the break in every case, yet even using the break statement my program keeps executing the default after the specific case code is ...
-2
votes
1
answer
101
views
Why is a test (100/100) leading to an unexpected output?
I am trying to learn python. In this context, I work on this exercise:
I take a fraction from the user (X/Y) and return a result
If Y is greater than X, I prompt the user to provide another fraction
...
-1
votes
2
answers
249
views
Breaking of infinite loop in turbo c
Whenever I forget to increment 'j' and hit run it becomes an infinite loop so what can we do to break the infinite loop in turbo c if I don't have the option of 'Break' on my keyboard?
what process ...
-2
votes
1
answer
126
views
Python break loop with one line of code without using enumerate()
If I want to add a break to my for or while loop at certain iteration can it be done without adding counter?
i=1
for line in zip(*input):
print(format_row.format(*line))
if i &...
-3
votes
2
answers
108
views
How do i break out of this while loop in Python?
def main():
dmn_options = ["lenovo", "rasbberrypi", "Exit"]
while True:
display_menu(dmn_options)
user_choice = select_single_l(dmn_options);print(user_choice)...
0
votes
0
answers
34
views
Copy multiple worksheets from workbook and create a new workbook and save this file to new destination with name change and break links
I am trying to take multiple worksheets from workbook and save them to a new workbook with a new name and destination. when I have (122, 222) to save multiple worksheets its doesn't let me run it only ...
0
votes
0
answers
84
views
Python - Print a line multiple times with a break after each line
I would like to print the same message multiple times, each on its own line, with a blank line in between.
This is what I'm hoping for:
This store is closed today
This store is closed today
This ...
-1
votes
2
answers
90
views
SyntaxError: invalid syntax for breaking a true while and print a cod
I want to print the "bye" after breaking the True while, but I'm having trouble.
Here is my code
while (True) :
number = (input("pleas enter a number : \n"))
if number == ...
0
votes
2
answers
155
views
Tkinter On/Off While loop
I'm trying to use Tkinter to start a while loop when pressing the "on" button from an option menu and stop that while loop when pressing the "off" from the option menu. The while ...
-1
votes
3
answers
131
views
When would the absence of "break" at the end of a while loop lead to infinite loops?
I created a silly function to see if a string contains digits or not.
def check_digit_placement(w):
if w.isalpha():
return True
else:
i=0
while True:
if w[i]...
2
votes
1
answer
42
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
3
answers
72
views
something wrong with my loop where array (String type) where each word is written, if not repeated in a loop, is written to a dynamic array
arr.add(mas[0]);
for(int i=1;i<mas.length;i++) {
for(int j=0;j<arr.size();j++) {
if(mas[i].equals(arr.get(j))||mas[i].equals("")){
break;
...
2
votes
2
answers
98
views
higher/lower game - how do I check if an input is an integer or not in a while loop
When my code checks if an input is an integer or string it goes into an infinite loop of outputting "invalid input" and "guess a number between 0-9" without giving the user a ...
-3
votes
1
answer
58
views
break in For Loop (have some issues)
So im currently using EPPLUS in C#, trying to get some data from an excel file. It's working BUT, break; makes my head go "boom-boom". There are segments in my for loop that if i put the ...
0
votes
1
answer
114
views
How to break FileList for loop Angular 16 in HttpClient Observable
I need break FileList FOR loop in error case in HttpClient Observable. I make a request with post method for upload 1 file for each loop iteration. This is my code, but not working, not breaking loop.
...
1
vote
0
answers
87
views
Why doesn't ruby have a block_return (return from block) [duplicate]
I can think of a number of cases where block_return or return_block would be useful, but particularly in the case of yield. For example, the common problem of something like:
def with_file(name)
f =...
-2
votes
1
answer
82
views
while loops that will never end [closed]
How do i get my code to stop running the non stop 2.
what am i doing wrong with this addition i =+ 2;
using System;
namespace TestingNewShit
{
class program
{
static void Main(string[] ...
1
vote
1
answer
145
views
Understanding how a break statement functions in zybook question for python 5.10.1
it's a weekend and my professor isn't answering emails, we went over break statements in class and I was sure I understood it, but I keep getting questions like this wrong (it wants you to show the ...
1
vote
1
answer
998
views
Break out of inner loop in a nested loop (BASH)
I decide to play around loop just to understand how loops work in bash.
But I am the one who got played.
All I know is the the break call helps to stop a particular loop
echo "For loop begins&...
0
votes
1
answer
402
views
Is there any keyword that will terminate or stop the simulation when the output reaches a specific value in open modelica?
I want to stop the simulation when my output reaches a certain limit or value irrespective of the simulation time. Let's take an example my output is 'prod' a variable which has the product of two ...
0
votes
1
answer
49
views
Cancelling input command upon user's request
I am a beginner. I am creating a very basic calculator.
I want to break the program when the user gives the command as "STOP". Here's my code:
while d=="yes" or d=="YES" ...
1
vote
1
answer
3k
views
How can I get out of two loops in Python, not only the inner one? [duplicate]
When the answer is "Non", i need to get out of both if loops to continue with the program and i dont know how to do so, it only breaks from the inner one.
this is my first proyect and im idk ...
0
votes
0
answers
330
views
Ruby Invalid break (SyntaxError)
I have an issue with very simple piece of code:
def cond(x,y)
if x =~ /#{y}/
puts "ok"
else
puts "not ok"
break
...
-1
votes
1
answer
68
views
Breaking nested loops and iteration [duplicate]
So here's simple structure of my code:
while condition:
for i in range(num):
for j in range(num):
if arr[i][j] == something:
#DO SOMETHING
#...
-3
votes
2
answers
56
views
break in running program in python [closed]
when i run this code in terminal** i should prees" enter " key to run after line 6 **
i dont know the problem
i'm in the learning python proccess
thank all of you in advance........
print(&...
-1
votes
1
answer
79
views
i can't exit while loop without using exit(). Neither break nor return don't exit the loop?
machine = True
money = 0
def game():
global money, machine
while machine:
order = input("What would you like? (espresso/latte/cappuccino) ") # Gets order
machine = ...
-2
votes
2
answers
1k
views
Usage of break in for loop
I am new to programming and I came across these two similar problems:
Example 1:
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
Output:
0 1 2 3 4
...
1
vote
3
answers
63
views
I need to remove the elements with repeated letters in the string
String1 = “Python is an interpreted high level general purpose programming language”
List1 = String1.split()
for i in List1:
for j in i:
if i.count(j)>1:
List1.remove(i)
...
2
votes
4
answers
176
views
How to exit an outer loop in C (without ++)?
In Java, it is possible to escape from an outer loop using such a construct:
int[][] matrix;
int value;
...
outer: {
for(int i=0; i<n; i++)
for (int j=0; j<m; j++)
if (matrix[i][j] ==...
-3
votes
1
answer
97
views
When Infinite Loop is opening at same time in Redhat Linux then how to stop it?
when some one attack like DDOS or Dos in our computer
for example someone like hacker let's say run infinite loop in your terminal to open the gnome-terminal
code:--
while :
do
gnome-terminal
done
...
0
votes
2
answers
94
views
Why does break work in switch blocks but not if-else blocks in C? [closed]
Just beginning with C and noticed this detail. Not a pressing question, just curious.
I tried searching for the answer but couldn't seem to find an explanation.
(not sure what else to say, this ...
6
votes
2
answers
3k
views
What is the benefit of 'break' in 'switch' statement (Dart Language)?
When I write this code
void main() {
var age = 18;
switch(age){
case 18:
print("Age is 18");
case 22:
print("Age is 22");
default:
print("...