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
answer963
viewsShuffle text
insira o código aqui[![inserir a descrição da imagem aqui][1]][1] shuffle text Rules: 1. Punctuation marks are word separators, are not part of words and so are not shuffled, for example: a)…
-
-1
votes2
answers81
viewsHelp with basic C program of the introduction to programming class
The exercise asks a program to read a binary number in the form of a 'char' vector from the keyboard and return its corresponding to base 10. I wrote a code but the values it returns are wrong,…
-
-1
votes1
answer88
viewsdisplay the result of a foreach outside the loop
Hello, I need to present the result of a foreach out of the loop. The way I have been doing only presents one result. What I’m doing wrong? //Check bad words $badWords = array('palavra1',…
-
-1
votes3
answers319
viewsBuild error in C++
I need to make a loop (Repeat-Until), but is giving error. #include <iostream> #include <cstdlib> using namespace std; int main (void){ char deseja=1, valordomes1, valordomes2,…
-
-1
votes4
answers84
viewsShow the output of a custom vector
I have a vector with 16 elements. I want to show the elements of this vector using the repetition loop for. Output must be equal to this: A 1 2 3 4 B A 5 6 7 8 B A 9 10 11 12 B A 13 14 15 16 B As…
-
-1
votes1
answer63
viewsFinite looping
I am transcribing from Java to Python a code to solve a Sudoku 4/4. When I test the code it doesn’t run and runs endlessly, apparently in one of the methods of the Artist class. Can someone help me…
-
-1
votes2
answers54
viewsfor/if PHP omitting element
I have a big problem. I have a PHP/LARAVEL system that issues PDF reports. The system it is omitting an element when placing it in an array. I believe it’s time to assemble the loop and make the…
-
-1
votes1
answer294
viewsDate +1 Month increment (considering days, month and year)
Here’s the thing, in a system I’m developing, I need to increment a date. Below follows the code that I managed to develop until the moment that this works perfectly for increment even considering…
-
-1
votes1
answer350
viewsHow can I create a loop per seconds in python without Sleep or delay
I’m developing a programming for EV3, with python, and what I wanted to know is: How can I create a loop per seconds, IE, I want that in a certain time in seconds, the robot does the actions…
-
-1
votes1
answer73
viewsCheck for loop object existence
I am running a loop that should iterate 30 times that corresponds to the days of the month... and this loop is iterated with data coming from the database that brings the days of registered items…
-
-1
votes1
answer95
viewsHow to pass a default parameter value within a foreach in C#?
Dear friends, How could I pass a default parameter value within a foreach? Example, inside my foreach I have an if that makes a certain comparison with an attribute of my class right?. But by…
-
-1
votes1
answer76
viewsHow to update Jtextarea in each loop iteration with Swingworker?
I have a class that inherits from SwingWorker and I’m getting information from a file .txt and playing for the JTextArea, and would like to go running update of JTextArea while the loop is running,…
-
-1
votes1
answer127
viewsHow to read String in the best way to use it as a halting condition of a loop?
I’m trying to ask for input to a string and read it as a halting condition of a loop but I’m not getting it. Logic Error. #include <stdio.h> #include <locale.h> #include…
-
-1
votes2
answers1396
viewsLoop inside loop While PYTHON
I’m making a program that draws a number from 0 to 5 and the user should guess what it is, but he only has 3 attempts. In case the 3 attempts run out and the user does not guess which is the number,…
-
-1
votes2
answers529
viewsChange array values using for and if
Hello, I have an array with several values. I would like to replace the values above -0.54 to 1 and the values below -0.54 to 0. Below is my results name array: array([-2.06133692, 0.3721 ,…
-
-1
votes1
answer29
viewsHow to adapt layout according to browser resizing?
I built a function to read the size of the window through which the user is accessing the site, compare with a standard break-point that I chose and then adapt the layout. I put an example of change…
-
-1
votes2
answers96
viewsPython loop requesting data reentry
I have a problem in my Python code, it is giving loop. Every time I have to insert the list again to show the results. Could someone help me? Follows the code: import numpy as np import pandas as pd…
-
-1
votes2
answers53
viewsAdd empty items at the end of array
This is what I need to do, and I’m not up to it. I have to create an array to generate a json output with 50 items for example, but if the database contains only 30 it completes the 50 items with…
-
-1
votes1
answer85
viewsI have a problem with the beginner python code
Good afternoon! I’m a beginner and I’m trying to learn python, I tried to make a program that calculated if the number typed is prime and then the program asks if I would like to calculate all the…
-
-1
votes6
answers1811
viewsLoop Array - Fruit
I’m trying to do an exercise, but it wasn’t the way the platform wanted, I’ve already spent a few hours trying because I’m beginner and I have no ideas how to solve, could help me? Enunciation: A…
-
-1
votes3
answers452
viewsJavascript - If and Loop
I’m trying to answer a question inside a platform, and I’m not being able to adjust the code as the algorithm wants. I am receiving the following errors : 1- You must have an if validating the…
-
-1
votes1
answer542
viewsHow to know how many times a word repeats in the array and,from the return of a function that calculates this,do new calculations?(JS)
I need to do a function that returns how many times the car board appears in the array and use this return in another function to determine a calculation. That’s my code and it’s printing "0" var…
-
-1
votes1
answer43
viewsOne Layer Perceptron Neural Network, Inputs
Hello I’m having a doubt about going through the input and data weight without using the numpy. #AND entrada = [[0,0],[0,1],[1,0],[1,1]] peso = [0.0,0.0] The way I figure it is : inada1 x weight +…
-
-1
votes1
answer23
viewsLoop Laravel making only one Insert in the bank, when it should do several
I’m not getting enough inserts in the database with a loop. At the time of insert, he only makes one. public function store(Request $request){ $contrato = new Contrato(); $contrato->cont_aluno =…
-
-1
votes1
answer44
viewsConditional to capture JSON information via Pyhton
If anyone can help me.. I have a Python script that reads a file. json that contains the web services I need to interact with. At first, my json only needed to contain a service and the script works…
-
-1
votes2
answers49
viewsHow to repeat div with json with dynamic content?
Right now I want to make a div have a JSON content. In this case, the first div has the "0" content of JSON, and that repeats itself in loop, until it reaches the maximum amount of items within…
-
-1
votes1
answer33
viewsRepetition with Json in JS
Hello, I am new to programming and am learning to use JSON with JS. This is the JSON I’m using: { "USD": { "code": "USD", "codein": "BRL", "name": "Dólar Comercial", "high": "5.564", "low":…
-
-1
votes3
answers300
viewsHow to use while and if in Python?
Forgive me if it’s a stupid question, but I’m a beginner. I have to use the while condition to finish the program. In this case, the code has to rotate while the weight is different from 0. And, if…
-
-1
votes1
answer44
viewsHow to define JSON properties to use in a for loop?
I’m reading a JSON that looks like this: Google Books and trying to display it in HTML. The user’s search input is the seek which is received through the request.form.get down below: import requests…
-
-1
votes2
answers42
viewsLoop is not walking, does not leave the first position
f3 <- function(n) { dados <- rnorm(n, mean = 0, sd = 1) matrizB <- matrix(0,2, n) for (i in 1:length(dados)) { s <- 1 if (i <= 0.2) { matrizB[1,] <- 1 matrizB[2,] <- 0.2 } if (i…
-
-1
votes0
answers25
viewsEquality Operator error != in Java
Good morning, I was training in Java and was building a form so I made a way that if the person enters an invalid data will run a do while with the same question (I don’t know if this is the right…
-
-2
votes1
answer523
viewsStructure of Repetition in Python
I need to solve the following equation in Python N is an integer and positive value. Calculate and show the value of E according to the following formula: E = 1 + 1/1! + 1/2! + 1/3! + ... + 1/N! My…
-
-2
votes2
answers5608
viewsCount how many times each character appears in a string (no function use)
I’m having the doubt in a matter of string exercises that I’m doing. The question is this below: Write a program that reads a string and prints how many times each character appears in this string…
-
-2
votes1
answer101
viewsProblem with array loop - Javascript
When I try to run the loop, even if I want to enter the is, I already checked and the array with the object is not empty, but does not execute the loop... Any idea? var caminho = [];…
-
-2
votes1
answer207
viewsWhat is the error in this while PHP?
The code below selects all the results whose thumbnail of the video has not yet been created and if it has not been, it creates a new one, but I am getting an error that I cannot find the solution:…
-
-2
votes1
answer46
viewsIs it possible to create dictionaries using surreptitious ties?
I was wondering if I could create a dictionary using loops. But I don’t want to create a dictionary within a list [{ }]. example: from random import randint jog = dict() for n in range(1, 5):…
-
-2
votes2
answers93
viewsHow to Loop a Java Object
An object does not have the same behavior as an object during a Javascript loop. That example: let obj = { casa1: { cor: 'azul', quartos: 2, }, casa2: { cor: 'vermelho', quartos: 4, }, } Does not…
-
-2
votes1
answer1122
views"String index out of range: 5"
There is an error mentioned in the question in my java program. The program is a barcode reader. The user informs the digits of the code (except the last one). The sum of the numbers q are in odd…
-
-2
votes1
answer39
viewsCalculate the product within a for loop
I need to calculate the product of 3 numbers inside a loop for, but the code I made is going wrong, multiplying something bizarre that I couldn’t even understand, for example, if I input 1, 1, 1, it…
-
-2
votes1
answer31
viewsStop Loop For when a certain number is typed
I’m trying to stop a loop for when the number 42 is typed. Even my code is like this: var numero = prompt('Digite o numero') var arrNumero = [] arrNumero.push(numero) console.log(arrNumero) for (let…
-
-2
votes0
answers36
viewsFor loop taking only the first df item, and xpath not returning value
I think the loop only takes the first number of the df print(span) appears 2, and xpath is returning empty in print(lucro_el), tried with the print(len(lucro_el)) and the answer was 0 span_index =…
-
-2
votes1
answer29
viewsPHP: Compare repeated items from a list and discard the one from the highest date
Good evening, I need some help with the code below: Inside the variable '$data' I have an array where the id repeats with different dates, I need to discard one of the two arrays repeated with the…
-
-2
votes1
answer63
viewsInsert Loop in C
I wish to insert an option for the user to type in how many rounds he wants to play against the cpu in this joquenpo game follows my code below, can any c master help me ? thanks #include…
-
-2
votes2
answers137
viewsA proposed infinity loop PYTHON exercise
HELLO, I’m trying to resolve the issue below, but I can’t make the LOOP work, since the exercise asks that even after choosing a type of average, the instruction comes back asking infinitely the…
-
-2
votes1
answer35
viewsRepeat loop does not leave first position
The exercise is: Using the function repeat, gere 1000 samples of normal distribution, each of equal sample size n and mean and standard deviation parameters equal to µ and σ, respectively. Choose…
-
-2
votes1
answer36
viewsHow to deal with arrays with different number of indices in the same loop
I have a script that makes a registration works like this: in a dynamic table, each row has an input that is checkbox type and it loads an id and another input is number type and loads any value…
-
-2
votes1
answer47
viewsWhich mode is it possible to add 5 out of 5 numbers and display by removing the previous ones each click on the increment/decrement button?
The intention is to run the first five [5] Carnidais numbers in sequence by displaying five-in-five, but the previous ones should be deleted and then run another five [10] (from 6 to 10) until…
-
-2
votes1
answer76
viewsProgram problem that traverses two lists and generates a third without repeating elements
For a little over a week I’ve been trying to solve the following exercise: "Make a program that traverses two lists and generates a third without repeating elements." The statement in question is…
-
-3
votes1
answer263
viewsHow gives an infinite loop
How do I treat the exception below: Fatal error: Maximum execution time of 30 seconds exceeded in ...
-
-3
votes1
answer691
viewsWhile listed in python
Could someone help with the following doubt? in "item", the goal is to loop from 0 to 50 id_rec = [conteudo['complainResult']['complains']['data'][item]['id']] I made the following code: item = 0…