FAQ Database Discussion Community


How to stop my function?

python-3.x,break
How do i get my function to stop, when a condition has been met? for example in my following code, when the user inputs: "q" for (quit), i want my function to simply stop. i've tried using the "break" statement, but it's not working. def main(): shape = input("Enter shape...

Python - attribute specific values with imbricated loops

python,for-loop,numpy,while-loop,break
I have some problems to store values with imbricated loops... It s an example which is close of my case. In order to limit the size of the code, i have added "a" as a random values. For each "image", i have to calculate dX and if i can reach...

How do I create a line break before the image of a PayPal button?

button,paypal,line,break,paragraph
So, I've already tried p and br tags, but for some reason nothing changed. How do I create a paragraph after the options? So the image jumps to the next line... I'm very lay at coding, anyone could help me? Here's the code I'm using: <form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input...

I was reading a post and someones comment confused me.

java,break
OK, so I was looking up the goto statement in java, and I stumbled on this post: Is there a goto statement in Java? (I know, I'm a scrub :P ) Anyways, I stumbled across this chuck of code in the comments: public static void main(String [] args) { boolean...

Why do most/all languages not have a multi-loop break function?

loops,break
I haven't seen any programming language that has a simple function to break out of nested loops. I'm wondering: Is there something at a low level making this impossible? Here is an example of what I mean (C#): while (true) { foreach (String s in myStrings) { break 2; //...

Vaadin layout break line without panel

layout,label,line,vaadin,break
I know it is possible for labels to automatically break lines when in a panel. Is there a way to have labels break lines when the text would be over a layouts width? UPDATE OK i tried it with "800px" width now instead of "100%" and now the labels are...

how to break out of a void method, if not with “return;”

java,switch-statement,break
How do I break out of a void method and get back to the switch method? public static void decrypt() throws FileNotFoundException { Scanner kbrd = new Scanner(System.in); System.out.println("Enter Key-file name: "); String filename = kbrd.nextLine(); System.out.println("Enter Message-filename: "); String mssgFilename = kbrd.nextLine(); String[] keyArray = loadMessage(filename); String[] message =...

Can I call functions between files encoded with ioncube?

php,break,ioncube
I just have a quick question regarding ioncube with PHP. Lets say I have a file, it has a function which I need to call throughout the project: function foo() { echo "bar"; } A different file //we must foo our bars!! foo(); If I encode the whole project with...

Java Loops - Break? Continue?

java,for-loop,break,continue
I've read through a bunch of threads on using break and continue and I suspect the problem isn't necessarily my use of those, but the layout of my loops. In the following code, I am trying to iterate through the chars in a string that is input by the user...

Java, cut off array line before charactern nr. X

java,arrays,string,break
So i have massive(i mean massive) array. It has over 500000 lines. Each line starts with some bs that i don't need. What i need is EVERYTHING after 64th symbol(65th symbol is needed). It's the same for every line, but after 64th symbol each line lenght is different. How do...

Insert break / sleep after showing a hidden button

ios,swift,hidden,viewcontroller,break
I want to make a button appear, then I want to show it for 1 second and after that the view controller has to change. I tried my best. but it doesn't matter where I put the sleep(1); - it always does the same. It waits for 1 second, then...

Why I'm the loop is breaking and getting error even after not satisfying the condition?

php,arrays,foreach,associative-array,break
I've following code snippet: $aSupportedImages = array('jpg', 'gif', 'png'); foreach($vshare as $file) { if(!in_array(pathinfo($file, PATHINFO_EXTENSION), $aSupportedImages)) $errArr = 'File extension of image is wrong'; echo $errArr; break; } The array $vshare is as follows(output of print_r($vshare);): Array ( [IMG_0004.jpg] => Array ( [0] => https://www.filepicker.io/api/file/UYUkZVHERGufB0enRbJo ) ) I'm not understanding...

Breaking from Switch at the right time

java,switch-statement,break
I am doing a sort of non-recursive approach to the Towers of Hanoi. I know that... 1) We move the first disk to the next available space (that is neither the last/current place the disk was in). 2) Move the next possible disk (that is not the first disk). 3)...

Python - I need a specific way of making multi-line input [duplicate]

python,text,input,line,break
This question already has an answer here: Multiline user input python 1 answer I need a to make multi-line input in Python. This is part of my program: input_ = input("Enter text:\n") #This can handle only single line of text Like this: Enter text: This is frst line, #Variable...

R - loop and break after value found for each Rows

r,loops,matrix,break
I have a matrix of 0-1. What I would like to do is to loop into this matrix and search for the 1. Each time a 1 has been found, to simply jump or pass that row, in order to only record 1 value per row. What I am trying...

Java breaking vs returning

java,switch-statement,boolean,break
I am using a boolean that returns true. When something like this happens: public boolean t(String label, String[] arguments) { boolean j = false; if (!j) { return true; } return true; } However, inside of this boolean I have a switch statement. As you may know, you break out...

In SQL, how do you add a line break to text AND display text in the Results window?

sql-server,output,line,break
I am trying to display harcoded text on two different lines and then display three tables after them. The problem I am having is getting the text and the tables to show in the same window. (is this even possible?) I took the code from (How to insert a line...

Trouble With Text Adventure Ending Between The Switch of Rooms

python,loops,text,input,break
I have a text adventure that ends between the switch of the rooms. I think it is the while room = '#' that I'm using so that the player can always put in input. I can switch from room 0 to room 1 but once I try to do vice...

While loop not breaking when condition met

python,python-2.7,loops,while-loop,break
I have a python code that tries to guess the user's age by asking some questions. The thing is that when the user's age equals to the variable the while loop won't break. Here's my code: age = 50 guess = raw_input("Give your age: ") while guess != age: print...

Break (or brake) a loop in this specific code - Python

python,while-loop,break
I was trying to create a "end" variable, that should break (or brake) but it clearly didn't work. The question from my homework: Modify the program above to give the user only 5 guesses. If there are more than 5 guesses, the user should get the following message: (in code)...

Continue or break did not work in ternary operator [duplicate]

java,loops,while-loop,break,continue
This question already has an answer here: Java: Ternary with no return. (For method calling) 5 answers I want to display multiples of 5 from 0 to 30 but not using normal logic. Tried with Ternary operator to display the result. int i=0; while(++i<=30) System.out.print(i%5==0?i:" "); Output 5 10...

How can I log the termination/any end of an SSIS package?

debugging,visual-studio-2012,ssis,sql-server-2012,break
I've got an SSIS package (targeting SQL Server 2012) and I'm currently debugging it. What I'm after is how to log that the SSIS package has finished or stopped by any methods. The closest ones look to be 'OnExecStatusChanged', 'OnPostExecute', and 'OnPostValidate' however NONE of these provide any log messages...

Is there a way to break from an array's reduce function in Swift?

arrays,swift,break,array-reduce
Is there a way to do something similar to break from a for loop but in array's reduce() function? E.g. consider I have an array: var flags = [false, false, true, false, false, true, false] ... and I need to get a cumulative || on them. With a for loop,...

What is the best way to exit loop in Java? [closed]

java,loops,while-loop,break
What is the best way to end a loop in Java? This: boolean exit = false; while((a < 5) && (exit = false)){ if(a == 3) exit = true; else a++; } Or this: while((a < 5){ if(a == 3) break; else a++; } ...

difference between continue 2 and break in nested loops

php,loops,break,continue
I was refactoring some old code and stumbled on a continue 2 that can be easily replaced with a break. for($rows as $i){ for($columns as $j){ if( Helper::unicornExists($i, $j) ){ //continue 2; break; } } } If we say that continue 2 makes the code more complicated and hard to...

How are the results for count different in all these three cases?

python,for-loop,while-loop,break
Code 1: iteration = 0 count = 0 while iteration < 5: for letter in "hello, world": count += 1 print "Iteration " + str(iteration) + "; count is: " + str(count) iteration += 1 Code 2: iteration = 0 while iteration < 5: count = 0 for letter in...

How “break” in iterative Python loop works

python,loops,iteration,break
Newbie here, so bear with me...I've tried researching this on Python.org and Google, it's still not clear to me what's happening here. The basic questions are: What is break doing in the following iterative loops? Why do both if statements work, even though one uses the ">=" and the other...

Ruby - Loop will not break

ruby,loops,break
I have written this code in Ruby for something for The Odin Project (Tic Tac Toe) and it won't break when @won is true. I can confirm that @won is becoming true but it won't break. The full code is at http://pastebin.com/GNJYC0hc b = Board.init b.create_squares b.display_board loop do if...

Switch too often triggered

php,loops,switch-statement,break
I cannot get my head around this. There might be a simple solution and the problem addressed already, but I could not find an answer. <?php $string = ''; $array = array(1, 2, 3); foreach($array as $number) { switch($number) { case '1': $string .= 'I '; case '2': $string .=...

How to break from nested loops without using label's

java,for-loop,break
Hello here is my code. int counter=0; for(int i=0;i<5;i++) { for(int j=0;j<5;j++) { System.out.println(++counter); if(counter==11) break; } } My question is how to end both loops when counter is equal to 11 ? In this example i just end the second loop. I know there is a way if i...

for loop over list break and continue

python,loops,for-loop,break
To specify the problem correctly :i apologize for the confusion Having doubts with breaking early from loop . I have folders - 1995,1996 to 2014 . Each folder has xml files. In some xml files the entry - MaxAmdLetterDate is None. I want to proceed to the next file in...

Python 2.7 Break function doesn't finish program

python,loops,break
I don't understand why the define gameover() is looped. As I think Break should break While, then define gameover() is completed. And nothing after it, it's mean the program should be terminated. I think that it is possible to rewrite, but I want to understand what is wrong in precisely...

How to delete or terminate rows in matlab

matlab,row,break
hi guys i want to delete or terminate rows containing d>8, here's my code fileID = fopen('d.csv','w'); fprintf(fileID, ' a, b, d \n'); for a = -3:3 for b= -3:3 d = a^2 + b^2; if d > 8 break; else fprintf(' %d, %d, %d, \n',a,b,d); end end end fclose(fileID);...

Press key to break a loop

c#,winforms,loops,keypress,break
C# windows form has problem that when a loop is executed, it disables all other events. So when a loop is too long, I can't stop the program properly (can't press the close button). Anyone know how to solve this problem, please help. To simplify the problem, here is a...

Neatest way to stop execution in a method

c#,break
Related to this question Suppose I have a long method which I want to abort on certain conditions. What's the best way to do this? Here are two ways I can think of. try { // if i is 0, we don't want to continue int i = testi(); if(i...

Line ChartJS empty / null values doesn't break the line

null,break,chartjs
I want to break the line of the chart when values is null or empty, but I can't. Perhaps I miss something? var data = { labels: ["January", "February", "March", "April", "May", "June", "July"], datasets: [ { label: "My First dataset", fillColor: "rgba(220,220,220,0.5)", strokeColor: "rgba(220,220,220,0.8)", highlightFill: "rgba(220,220,220,0.75)", highlightStroke: "rgba(220,220,220,1)", data:...

Why will this only work with break;?

loops,nested-loops,break
1) Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10). Once the data has been entered, the program must analyze the data and output which person ate the most pancakes for breakfast....

break and continue doesn't work in Java

java,break
I made this program which reverses a string. It can be done in two ways. so I want to ask user the preferred method. for getting out of the if else I use break keyword followed by a label for each choice. This program works fine without break and label...

Adding line breaks every x characters (using jquery / angular)

jquery,angularjs,line,break
I'd like to automatically add a new line break every 10 characters with this code : HTML : <div ng-app=""> <textarea id="chat" ng-model="msg"></textarea> <span class="msg" ng-bind="msg"></span> </div> Naturally when I type something in the textarea, it appears below in the span. But I want it to work like there is...