Most voted "loop" questions
Loops are a type of flow control structure in programming in which a series of statements can be run repeatedly until some condition is satisfied.
Learn more…671 questions
Sort by count of
-
1
votes1
answer161
views -
1
votes1
answer37
viewsCreate loop and move to arguments of a function?
I have the following code in Python: storage.tableWidget.setColumnWidth(0, 30) storage.tableWidget.setColumnWidth(1, 140) storage.tableWidget.setColumnWidth(2, 90)…
-
1
votes2
answers168
viewsWould you like to make a code that spells out the word?
I’m new to programming and I’m trying to put together a script where I type in a word and he spells it out for me! I’ve assembled the following code! nome = input('palavra para soletrar:') while…
-
1
votes1
answer130
viewsWhy does this goroutin loop just repeat the last value?
This loop is always repeating the last value, consider the following: type unique struct { id, nonce uint64 } func (unique *unique) print() { fmt.Println(unique.id) } func main() { teste :=…
-
1
votes2
answers9649
viewsAutomatically fill cells in excel using VBA
Good afternoon community, I am trying to work with VBA in Excel in order to try to apply this knowledge in my master’s thesis, but I have some doubts. I am trying to create a VBA function that fills…
-
1
votes1
answer65
views -
1
votes3
answers467
viewsHow to get an advanced "for" score?
I was wondering if I could get some kind of control variable, from a for "advanced". For example: In a be normal, I do it this way: for (int i = 0; i < algumaCoisa.size() ou length; i++){…
-
1
votes1
answer488
viewsLoop to Add values from a db
I’m making a financial control system, and I looped while to take the client data from a db and show them on a table. What I want to do is take the values of the column "PRICE" and add, to give the…
-
1
votes1
answer85
viewsHow to return array indices in method
Well I couldn’t find a better title for my case, I have the following function: public function select_tokens() { $sql = "SELECT * FROM `users`"; $select_tokens = Database::DB()->prepare($sql);…
-
1
votes1
answer64
viewsHelps in the logic of conditions and repetition in C++
I have the following verification code to know if a certain number belongs to a vector. I couldn’t think of a more precise way to get the program to say that the number DOES NOT belong to the…
-
1
votes2
answers219
viewsLoop memory and processing optimization
The code is simple and is working perfectly, but wanted tips on how to optimize it, what would be the best methods to use to allocate less memory, best practices, etc. using System; using…
-
1
votes2
answers422
viewsLoop to Repeat Names
Dear community, I believe it is simple the most solution, I am trying to make the following rule of business: I have a list of names on a Plan1, I need the name of each of them to be repeated by 12x…
-
1
votes1
answer40
viewsHow do I do a repeat structure function on R?
I’m trying this way: H <- function(n) { for (i in 1:length(n)) { x <- 0 a <- 2 b <- 3 func = x + a/b a+2 b+2 return(func) } } Does anyone know how to solve?…
-
1
votes1
answer37
viewsRemoval of automated outilers
I need to remove outliers from a database in a "manual" way, I would use the following command: a=X Q1<-quantile(X,0.25) Q3<-quantile(X,0.75) IQR<-Q3-Q1 lim_inf=Q1-1.5*IQR…
-
1
votes2
answers754
viewsLoop for ATM
I need to run this code until user asks to quit. In case, it will inform the result at the end and follow up with a question to the user if he wants to continue using, then the code runs again until…
-
1
votes1
answer131
viewsHow to open different web pages using while
I would like the program to perform the repetition of a command 3 times: wait 10 seconds to open a web page. For this repetition to occur I set the code below: import time import webbrowser…
-
1
votes0
answers69
viewsHow to make an infowindow with different content for each marker in a loop
I’m trying to make each marker in this loop have an infowindow with different content, the arrays are the same size and are being taken from the database, the problem is that by creating new…
-
1
votes3
answers97
viewsExecution or not of the increment in loops for
Code 1: var x = 1; for( ; x<6 ; x+=2 ){ x=x*x; } console.log(x); In the above code even if the condition is false the incrementing part is last executed. Code 2: var x = 0; for( ; x<8 ; x++…
-
1
votes2
answers96
views -
1
votes0
answers26
viewsDoubt About Variable and Function
I am starting in Python, with the following characteristics: -User enters temperature limit -I read the user temperature compared to the sensor temperature -If Sensor Temperature is > User…
-
1
votes1
answer82
viewsCan someone please explain some of that code to me?
The code in question is the bottom one, a lot of it I’m understanding more the loop for confused me, it gets the sequence of the variable, but in print, it informs exactly the sequence that the user…
-
1
votes0
answers423
viewsLoop, For, PL/SQL cursors (Doubt)
Good morning Guys, my doubt is the following, my table is so currently: Nome Idade ID João 5 Lucas 5 João 2 Lucas 1 I wish she’d stay that way: Nome Idade ID João 2 1 João 5 2 Lucas 1 1 Lucas 5 2…
-
1
votes2
answers592
viewsHow does Length work outside and inside For in Javascript?
I have a constant doubt about the Length and the noose for to measure an array or a string. Doubt 1: When we use that code: const numero ="teste"; const medir = numero.length; console.log(medir) It…
-
1
votes3
answers268
viewsError when calculating a loop value
#O usuário informa o número de alunos totais na sala, em seguida são declaradas as variáveis que complementarão os loops alunos = int(input("Qual o número de alunos na sala?\n")) notasAlunos = []…
-
1
votes1
answer64
viewsUse of repeat loop appropriately
"A very common joke among 3 friends is the game of 2 or 1. In this game, the winner is different from the other two and, if the three choose equal values, the game ends tied. So consider three…
-
1
votes1
answer2436
viewsUndefined method `+' for nil:Nilclass - Ruby error
I have the following Ruby codes in three different files. Follow them: Rb program. require_relative "product" require_relative "store" cd = Product.new("CD",20.5) pinico = Product.new("Pinico",30.6)…
-
1
votes1
answer155
viewsjquery how to receive data line by line in a loop
In the test.php file I have: <?php echo "<input type='button' value='Envia' class='btenvia'/><br><br>"; echo "<div id='mostradados'></div>"; ?> <script…
-
1
votes2
answers131
viewsLoop logic with for
Consider the Javascript code below. var r = [2, 5, 6, 18, 20, 10, 23, 12, 19, 10]; var s = [1, 5, 7, 13, 18, 21, 10, 25, 32, 17, 3]; var x = [0]; var i; for (i = 0; i <= 9; i++) { x[i] = r[i]; }…
-
1
votes2
answers352
viewsDifficulty with nested FOR loop
I am creating a code to develop my studies in java and gave me an idea/ interesting challenge: One person has 5 Megasena cards and always plays with the same cards. I made a little code where you…
-
1
votes2
answers522
viewsInfinite loop on switch
The problem is that in all three cases, cout repeats endlessly. #include<iostream> using namespace std; #include<locale.h> int main(){ setlocale(LC_ALL, "Portuguese"); bool a; int…
-
1
votes1
answer72
viewsDifficulty implementing chess board
I need to implement the code that manages a chess board in ppm. It would be in the standard 8x8 format, with the option of the user to set the pixel number, the doubt would be when to loop to…
-
1
votes1
answer82
viewsI am trying to print an array using for in javascript, but it is not displayed correctly
I printed it manually and then tried using a for to carry out the printing, but I happen not to be able to display it properly. let mochila = new Array(); let item1 = ['corda', 2], item2 = ['faca',…
-
1
votes2
answers1085
viewsReturn to previous menu
I’m trying to add a "Back" from one menu to the other, first tried using the do only in the 2nd. menu to return to the first, but it only closes. Follow the whole code: namespace ConsoleApp10 {…
-
1
votes1
answer97
viewsLoop does not perform everything it should
I have a problem in my program, I need it to show randomly an order of numbers (teams). The problem is that when I put a number greater than 10 it doesn’t show the 10, it only shows a few: int…
-
1
votes1
answer98
viewsIterate values of two requests in *ngFor
I am making two requests in the bank, one brings the orders grouped only for view on the front, the other brings all values, the last need to show the total of each request along with the view of…
-
1
votes1
answer198
viewsWarning looping Python Pandas, How to make the looping differently?
Guys I’m doing this looping here: for i in range(1, len(candles)): if candles['askclose'][i]> candles['askopen'][i]: candles['Fechamento'][i]= 'alta' But the jupyternotebook always returns me…
-
1
votes1
answer70
viewsTry-catch in loop causing error
I have the following code, which tries to click a button after 60 seconds, and if it has not pressed, try again after 60 seconds. while(true) { var timeout = setTimeout(function() { try{…
-
1
votes2
answers1269
viewsATM simulator
I’m starting to build a program that simulates an ATM with 3 banking options and an option for the user to terminate the process. Only after the operation done by the user, I tried using the…
-
1
votes1
answer73
viewsSingle-line save in DB, the result of the PHP variable (WHILE/LOOP) of a MYSQL Query
I have the following problem: When performing a query, the while result is composed of more than one value, for example: $query_sku = mysqli_query($connect, "SELECT t.column_name FROM skus AS s…
-
1
votes1
answer176
viewsjQuery / Select the item within an array, referring to the position of the loop
Good afternoon friends, I’m having trouble finding a logical solution to solve my problem in a loop (for) Inside a table, we have a price information on the tag: <p…
-
1
votes1
answer513
viewsObject counter by an infrared sensor on Raspberry with Python
Hello friends I made an object counter using an infrared sensor and Python, but would like help to refine the code. Because this counter of mine has a problem, if the object stops in front of the…
-
1
votes4
answers3686
viewsSumming value by value in an array with Python
I need to sum up all the possible values within one array to find out where an error is in a database. Code until then: valores =…
-
1
votes0
answers32
viewsShow only a few page numbers of the pagination instead of all
I made a pagination that is appearing every page: I need it to look like this: << < 1 2 3 4 5 6 7... 50 > >> << < 4 5 6 7 8 9 10 ..60 > >> I’m researching and…
-
1
votes4
answers84
viewsHow to do a sequential for with nodejs version 8?
The nodejs version is: V8.10.0 I don’t know much about Ode. In this specific case I need the next iteration to be executed only after the previous iteration has been completed. Also, I need that…
-
1
votes2
answers177
viewsWhy is the code not running the for loop, even though the compiler is not showing an error?
I was doing an exercise on vectors, where the goal was to build a program that received a number n for input that would define the size of the vector, and then receive, also by input, others n…
-
1
votes1
answer150
viewsLoop Problem and Time Calculation
I want to do a program, where he reads an activity, and the time spent on it. Example: Lavando o Portão, 10:30 as 12:00, tempo gasto 01:30 I am currently with 3 problems: The way my code is…
-
1
votes1
answer32
viewsReceive the numeric keys to make some functions equal for all of them on the switch in a calculator
switch (e.target.value) { case "A/C": console.log('ae') break; case "C": break; case "X": break; case ".": break; case "%": break; case "-": break; case "√": break; case "+": break; case "÷": break;…
-
1
votes0
answers894
viewsJavascript Two-Dimensional Array
Hello, I have a two-dimensional array as follows var array= [[{"id": 23, "nome": "Daniel"}, {"id": 24, "nome": "Bruno"}, {"id": 25, "nome": "Guilherme"}], [{"id": 1, "nome": "Luiz"}], [{"id": 2,…
-
1
votes2
answers110
viewsLoop Javascript for (...)
Talk, you guys, blz? Today I tried to make a Dropzone clone just to test the File and Filereader api. However, I think I’m missing some loop concept. According to the loop interaction, I take the…
-
1
votes2
answers562
viewsHow to go through two lists of different sizes [PYTHON]?
The idea is as follows: Each team has 6 maps played (mapList) I made a web Rawler that takes all the information related to the team and the map and wanted to insert automatically in a spreadsheet…