Most voted "for" questions
Use this tag when the question primarily involves logic and/or command structure. Effectively, the for is a loop of repetition used to iterate matrices, vectors, or to another end that basically has three components: start, stop condition, and step, where it is usually possible to omit some of these components (although not very recommended).
Learn more…446 questions
Sort by count of
-
0
votes1
answer272
viewshow to make React render a table
I’m trying to make a table , 5 tall by 7 wide , inside the React , however, when I tried to run the 2° for loop he does not recognize and ends up not doing the action , obg by help S2 function…
-
0
votes0
answers56
viewsLoop for was supposed to run 5 times, but runs only 1
So I’m having a problem with a loop for in the code below: for i=1,#collisionBlocks do t=collisionBlocks[i] print(#collisionBlocks) print(i) if player.y-1<t[4] and player.y-1>t[2] and…
-
0
votes0
answers10
viewsHow to generate different numbers
Why my code is sending me 2 equal numbers? for(int i = 0; i < 2; i++) { Random numAleatorio = new Random(); int valorInteiro = numAleatorio.Next(10000, 99999); Console.WriteLine(valorInteiro); }…
-
0
votes2
answers64
viewsHow to mount a number 1 pyramid of 20 consecutive lines?
I have the code: let i = 0 for(i = 0; i<= 20; i++){ const p = 1**i console.log(p) } And I expect a way out like: 1 11 111 1111 11111 111111 1111111 11111111 But I’m failing to create this form of…
-
0
votes2
answers67
viewsCheck with php and disable option
I know what you have to do, but I don’t know how to do it. I have the following array: $dados = array 0 => array 'id' => 1 'posicao' => 1 'ativo' => 'sim' 1 => array 'id' => 2…
-
0
votes0
answers467
viewsHow do I add 2 (binary)? Python
I want to add 2 to a binary number that the user enters and then add 2 binary values. EX: 111001 - 110001, I make the complement of 2 in the second number and then I make the sum of these values, I…
-
0
votes3
answers2698
viewsSeparate even and odd numbers with two vectors in C
I have the following problem: I need to read several numbers until the number typed is 0 or one of the vectors is fully filled, in case the vector must have a maximum of 10 indexes, and for each…
-
0
votes1
answer75
viewsExpected operando in for loop shell script
I am creating a function in shell script that says if the number is prime or not, but I am getting a syntax error in for loop that the function has and I could not find how to fix. # ... 9 ehPrimo()…
-
0
votes2
answers477
viewsI need help to calculate the factorial in ascending and descending order in an equation!
I need to resolve this question: Make a program that reads the number of terms and a positive value for X. Calculate and show the value of the following series: * S = (-X2/! 1) (+X3/2! ) (-X4/3! )…
-
0
votes1
answer128
viewsHow to use v-for with components, using array?
I’m using the question below to better illustrate my question. Vue is not rendering table with v-for, how to solve? How do I do the same thing? Only by displaying a listing, using a component, but…
-
0
votes1
answer48
viewsHow to know how many times the highest value was read (without list)?
I am doing an exercise where I must print the highest value of the numbers typed and how many times this higher value was typed. I tried to put the qnt += 1 but it’s not working. qnt = 0 num_lidos =…
-
0
votes2
answers109
viewsIterating a string inside the for
As for can pick up the string backwards using Len with -1 -1 -1? nome = 'felipe' for c in range(len(nome)-1, -1, -1): print(nome[c], c)…
-
0
votes2
answers33
viewsRoutine doesn’t work
I have a loop for the user to enter the student’s name and age. but when compiling, the first part of asking the student’s name is passing by and already falls asking the student’s age. follows the…
-
0
votes1
answer66
viewsloop for Jinj2 flask
I have a loop 'for" in the template only I want it to show a certain amount result. {% for form in form %} <tr> <td><img src="../static/img/arrow-gray.png" alt=""> <font…
-
0
votes1
answer38
viewsProblems with logic in a program
//EXERCICIO 103 //VERIFICAR SE UM NÚMERO É PRIMO #include<stdio.h> #include<locale.h> main(){ setlocale(LC_ALL,""); int n,k,cont,div; printf("Informe um número: "); scanf("%d",&n);…
-
0
votes2
answers60
viewsR Regression by condition using apply or for
I have the following sample: x <- structure(list(POP = structure(c(1L, 12L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L, 14L), .Label = c("pop1", "pop10",…
-
0
votes2
answers299
viewsR how to extract the first value from a date list.
I have this list of data:: base_list <- list(structure(list(POP_84 = 17.7, POP_92 = 18.8, POP_99 = 19.7, POP_02 = 20.5, POP_04 = 21.2, POP_09 = 23, POP_11 = 24.5), row.names = 149L, class =…
-
0
votes1
answer40
viewsHow do I guarantee unique numbers on a list of lists?
Good evening, I’m trying to make a 5x5 bingo card, using Andom to generate the values, however there can be no equal numbers. I tried to do it that way but it still comes up equal numbers: import…
-
0
votes1
answer719
viewsCalling functions using buttons
In the code below I created a graphical interface with some buttons, but when I click on the buttons they do not call the function. I didn’t find the error, I ask for help. # Importando a biblioteca…
-
0
votes2
answers250
viewsRun FOR cycle within another FOR cycle
for(int g=0;g<vl.VerbsList.length;g++){ // primeiro loop ok for(int h=0;h<TextParts.length;h++){ //segundo loop deveria ser executada por inteiro for(int j =0;j<BaseWord.length();j++){ try{…
-
0
votes1
answer67
viewsInsert data into a Javascript array #NODE ERROR( EMFILE: Too Many open files, open )
I have 3 arrays in my code, INFO, INFOS AND TEST. And I need to make a function check if the position of my test variable is equal to my info variable and if it is equal, the final variable is: In…
-
0
votes2
answers73
viewsI can’t understand my mistake with FOR and Dataframe
I have a problem in my for, where all the results are coming out as the same value within Dataframe, but I can’t understand the error, someone could help me import pandas as pd…
-
0
votes2
answers102
viewsHow to create an Animation in Javascript using For
I’m trying to make a Div have the background changed to the three primary colors in case Yellow, Blue and Red, however would only start to change the color 4 seconds after the page is updated, wrote…
-
0
votes1
answer210
viewsHow to show all values of three matrices in a single message without using indexes
package AlgoritmosII; import javax.swing.*; public class Trabalho1 { public static void main(String[] args){ String[][] A = new String[3][3]; int[][] B = new int[3][3]; double[][] C = new…
-
0
votes1
answer74
viewsDuplicate Data Loop Query Nodejs
I’m having a problem with a loop loop on node js, this is the query exports.getValueMsg = function() { return new Promise((resolve, reject) => { pconn .pool .query("SELECT b.numero_serie,…
-
0
votes0
answers286
viewsDoubt in a code to calculate the growth of a tree
I am having some difficulties to make this code below work. The statement of the exercise is this: Utopian trees grow in a particular way in two cycles: Each spring doubles its size each summer grow…
-
0
votes1
answer205
viewsUse of For Cycle and Arrays
There are two exercises that I need to solve using a cycle (or loop) FOR... In one of them, I need to catch one array x as a parameter in a function, and multiply all its elements among themselves…
-
0
votes1
answer80
views -
0
votes1
answer309
viewsTraverse array with Indice string
I am trying to traverse an array where the returned index is string (are names). I know how to walk when they come with 0,1,2,3... but with string I’m struggling. The return is as follows: Aatrox:…
-
0
votes1
answer148
viewsWhy does this "for" with double condition give infinite loop?
According to this documentation of the loop for in Javascript, the second expression is a condition: for ([inicialização]; [condição]; [expressão final]) declaração If I make a condition like this:…
-
0
votes1
answer799
viewsHow do I use if inside the for, without the outside if appearing?
printf("\nDigite o usuario que deseja pesquisa, pela Matricula: \n"); gets(strL); busca=atoi(strL); for(i=0; i<quant; i++) { if(busca==dados[i].matricula) { printf("Aluno: %d\n",i); printf("Nome:…
-
0
votes1
answer27
viewsPrintable images with the Pillow library
I am developing an automatic certificate issuance project where I use the pandas to pull the names of a spreadsheet and Pillow to write the names in the certificate. The problem occurs when printing…
-
0
votes2
answers40
viewsHow to use "for" to work with data in an array whose amount of varied data is unknown?
I have the following JSON variable resulting from a php query: $json_string = '[ { "id": 1, "name": "Jogos para PC", "products": [ { "id": 34, "name": "Grand Theft Auto V" }, { "id": 59, "name":…
-
0
votes1
answer71
viewsUnity C# | Problem Using For Loop Inside Update()
Hello, My problem is this, I have a list of events that happen at a certain time, which is randomized, and when an event occurs a new timer is drawn to the next one adding another 10 seconds, all…
-
0
votes1
answer89
viewsRun SQL Query multiple times between two dates (MYSQL)
I wonder how I do to run an SQL query between two dates where for example: the user will choose two dates: starting date = 20/04/2020 final date = 25/04/2020 so I wanted to know how do I do to do…
-
0
votes0
answers92
viewsCreating a Quiz in Django and Javascript
I’m doing a quiz in Django and using Javascript as well. However, I want each question to create a dictionary containing the question, options and the correct option. I was doing it that way: const…
-
0
votes2
answers116
views -
0
votes1
answer94
viewsHelp with a javascript code (Beginner)
They gave me an exercise but when I send it to see if it’s right they tell me it’s wrong, that it’s not returning the correct value. To be more exact they claim that: - The function summeDe25(10)…
-
0
votes1
answer489
viewsRender Dynamic Input Values - Vuejs
I am doing a project with Vuejs that has 1 form and its data is rendered on the screen, however, this form has options to add more inputs and consequently render this data as well. Then I get input…
-
0
votes1
answer55
viewsLoop for resetting the control variable in c++ Qt Creator
Good night. I’m making a program that converts numerical bases into Qt Creator using C++, and the function that converts from any base to decimal, has a loop for: int toDeci(QString str, int base) {…
-
0
votes1
answer62
viewsCount occurrence of events traversing columns of a dataframe through a for loop in R
Hello, I am using the table() function of R to count the repeated notes in each semester column (sem1, sem2,sem3...) of my file. It’s working properly, but I’d like to do it through a loop for and…
-
0
votes0
answers68
viewsA I am trying to fill a table through a loop loop, but it is taking too long. How can I improve loop performance?
the columns and table values will be filled in as the cycle runs. Briefly, I have a table with customer data (BD) and another table with expected future values by age (ESP). And what the cycle does…
-
0
votes1
answer80
viewsConvert for to while
#include <stdio.h> #include <stdlib.h> int main(void) { int X[10], cont; cont=0; while(cont<10){ printf("Digite um numero inteiro: "); scanf("%d",&X[cont]); if(X[cont] %2 == 0){…
-
0
votes1
answer58
viewsHow to use i no for value in a function?
I have the following code: select = Select(driver.find_element_by_id('Identificador')).select_by_visible_text('Maio/2019') form = driver.find_element_by_name('Formulario')…
-
0
votes1
answer39
viewsStoring data from a for in a dataframe
I have airport codes and needed to store the data access link of these airports in a DF, I tried to do through a for, but is returning error. Code I used: aeroportos <- c("bsb", "cgh", "gru",…
-
0
votes2
answers102
viewsrotate a "for" loop with 5 variables together
Use a program to create audio files called stem which combines vocals, drums, melody, bass and an audio guide into a single file. I am trying to create a loop that stores these files and so the…
-
0
votes1
answer348
viewsHow to do for instantiating a new JAVA object
I’m in my first object-oriented programming classes and I’m having difficulty with an evaluation. Create a class with at least 10 attributes for creating objects of the Computer type. The class must…
-
0
votes1
answer83
viewsInvert string in C - String problem with even number of characters
Well, I have the code below that should reverse a string and show if it is a palindrome. However, when the word has an even number of characters the result is wrong. I think the error is in the…
-
0
votes1
answer37
viewsSeparate MYSQL results by specific field for email triggering
I’m making an availability notification system (let me know) but I’m having difficulties in logic to make the iteration on LOOP grouping the results by "email" to trigger separately. CONSULTATION…
-
0
votes0
answers55
viewsHow to stop a for inside a while (Python)
I’m doing a facial recognition so I’m using a while to process the video and inside the while has 3 for and inside one of them where I left a comment "#STOP HERE" and where I need a stop because…