2,615 questions
0
votes
1
answer
43
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
113
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 ...
0
votes
0
answers
36
views
Using keyboard.read_key to quit a program on a condition
I'm trying to add functionality to my first project, a number guessing game. I want to allow the user to either enter a number to guess, or press escape to exit the program.
I've contained an if else ...
-4
votes
1
answer
67
views
I can't stop my program in python, please help me
month =
{"January" : "01",
"February" : "02" ,
"March" : "03",
"April" : "04",
"May"...
0
votes
1
answer
61
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
63
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
61
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
67
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 ...
0
votes
1
answer
36
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
38
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
65
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
173
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
32
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
52
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 ...
0
votes
0
answers
28
views
how could you use array for unit conversion of 4 different units
Based off the user’s selection accept a number from the user to be entered as that unit. Both
integer (eg 1) and floating-point numbers (eg 1.23) should be accepted. Ask the user to select which unit ...
-2
votes
1
answer
75
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
...
-2
votes
1
answer
60
views
Function not getting called/throwing exception in Java code
import java.util.*;
public class oops{
public static void main(String args[]){
System.out.println("Enter the username you want to set the for your Bank Account");
Scanner ...
-1
votes
2
answers
166
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
81
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 &...
0
votes
0
answers
72
views
How to avoid "'do/while/for' statement does not loop" warnings when attempting to always execute a call when exiting it?
I'm developing some Test scripts that always log a all of the successes/failures of the Testcase steps up to that point to my Test app of choice (and end the test as soon as there's a failure). So I ...
-3
votes
2
answers
96
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
29
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
81
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
85
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
0
answers
46
views
excel debugger active and prevent to run another excel file properly
I create a excel file with user login form that works correctly .when user open the excel file, login form appear and he can insert username and password and login easily. but the problem is that: if ...
0
votes
2
answers
136
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
120
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
40
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
63
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
96
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
48
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
95
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
86
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
78
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
114
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
708
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
237
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
42
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
2k
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
266
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
65
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
51
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
71
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
936
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
58
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
132
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
65
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
90
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 ...
3
votes
2
answers
2k
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("...