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
-
0
votes2
answers60
viewsIs there any way to use methods within other python methods?
I wonder if in Python it is possible to create a loop for within a format()? Example #Considerando: z=(1,2,3,4) print(f'''os números pares foram { for i%2==0 in z: print(i,end='são números pares')…
-
0
votes2
answers63
viewsEdit date value within a dataframe
I have this Dataframe and the date is in the following format: '2020-08-01' I would like to write a loop that iterates on each line and performs the switch to the following format: '01/08' I’m using…
-
0
votes2
answers48
viewsHow to add spaces before a number?
I’m trying to add spaces before numbers. The first code worked, but I wanted to do it in the form of loop. Sub numeros() numero = Range("A2").Value n = 3 If Len(Range("A" & n).Value) = 3 Then…
-
0
votes1
answer59
views -
0
votes2
answers313
viewsFill list and finish python loop
I need help on a problem that asks me to fill in by adding data to a list until it is declared 'end'. E=[] i=0 E.append(input('Nome do elemento?')) while (i!=fim): E.append(input('Nome do…
-
0
votes1
answer48
viewsHow do I make the code read a new value if the condition is not met? - C
The code is this, it’s in C #include <stdio.h> int main(void){ int i; printf("digite um inteiro"); scanf("%d",&i); while(i>=1){ printf("%d\n",i); i=i-1; } } But I want you to enter an…
-
0
votes1
answer583
viewsC++ While iterator skipping Cin.getline reading
I am starting in C++, during some tests I noticed that after the second iteration of while the Cin.getline command was not read displaying the line after it. I don’t understand what happens. Follow…
-
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
votes0
answers19
viewsDifference Cout and printf c++
I’ve been looking for content about the difference of Cout and printf for a while, but I still can’t find an easy, simple and direct explanation. I would like to know relationships about…
-
0
votes1
answer253
viewsHow to paginate a foreach of a file_get_contents?
I am consulting an API that provides me data formatted in JSON, I collect it through file_get_contents and then print all the values using a foreach. However there are many values, more than 5,000…
-
0
votes1
answer212
viewsForeach returning only one object in the list
I have a JSP page and in it I want a list. For this, I created a method listarTodos() within the DAO class and set the fields to display the object data, thus leaving the code: </div> <%…
-
0
votes1
answer234
viewsString for an array within a loop - javascript/nodejs
i want to pass the strings of a txt file to an array and as soon as each line was passed to the array the program would run it normally, then he would repeat and pick up the second string of the txt…
-
0
votes0
answers19
viewsLoop to search Twitter for various elements of a list using tweepy
I am using tweepy to return 20 tweets from each user in INF_LIST. I’m trying to do this by way of a loop so that it covers all users. However, it seems that the program returns only the last user’s…
-
0
votes2
answers1613
viewsPlace two Arrays inside a foreach
Well, in case I have two arrays that are received from inputs, based on renting rooms from a hotel, in case each room needs to display number of adults and children, I got help from someone here in…
-
0
votes1
answer325
viewsCode with indeterminate entries, showing pairs in ascending and odd order in descending order
I’m doing an exercise where the user places an indeterminate amount of numbers and they have to be presented by dividing the pairs of the odd ones, being the pairs increasingly and the odd…
-
0
votes1
answer31
viewsloop to replicate a dataframe in R
I have the following dataframe: df <- data.frame(x1 = 1:7,x2 = 8:14, x3 = 15:21, x4 = 23:29, x5 = 30:36) I need to replicate the value of each row 150, 100, 60, 43 times and for each column. I…
-
0
votes2
answers768
viewsCommand "goto" creating infinite loop in "for" loop
I want to simulate a school database that collects name, math and physics grades and averages both for 5 students (defined in a string of struct). Any grade above 10 would be allowed, without any…
-
0
votes0
answers59
viewsLoop interrupts script, but does not give error
I am putting together a list that collects user data. As some data is in different tables (attachments, precisely) I have put together a query select to capture only those attachments having the…
-
0
votes3
answers1242
viewsPHP-Loop repetition table using multidimensional array
Hello, I need to make a table like the one in the image but using this array: $teste = array(); $teste[0]['produtos']['nome'] = "Produto 1"; $teste[0]['produtos']['descricao'] = "Descrição do…
-
0
votes2
answers75
viewsJavascript for Loop - Incomplete and duplicated content
I have a UL that contain some news, inside it the news is inside li's. In this the first tag takes the headline and the link of the article. <ul> <li> <img src="" alt=""> <a…
-
0
votes3
answers116
viewsSave multiple records in the bank
I’m using the following code unsuccessfully. $conn = mysqli_connect('localhost','user','pass','banco'); try { $body = file_get_contents("php://input"); $dados = json_decode($body); foreach($dados as…
-
0
votes1
answer318
viewsHow to set up a common java project, host and run on a server
Whoa, good night guys, so with some questions about java systems running without server. Some friends and I are developing a java integration project (we receive information from a server/service,…
-
0
votes2
answers80
viewsGroup of bootstrap Gird images staying out of loop
I have a list of images where I am using in grid to organize them getting the exact amount I need by lines. With this I made a loop to control the grids and I also have the loop of the images.…
-
0
votes1
answer50
viewsLoop loop in Listview
Can someone help me? In a listview where the data comes from an internet database I can’t let it be automatic so that all values coming are included, the only way is to add one by one, but when as…
-
0
votes2
answers283
viewsConcatenation of items from a nested loop array
I would like to pick up the items in var a, a Bi-dimensional Array, and make an iteration in a nested loop, concatenating everything in order to place them between brackets, separated by a bar, as…
-
0
votes1
answer30
viewsCheck if Node created with insertAdjacentHTML in a loop is "visible"
I’m looking for fragments of HTML with fetch() and adding to the DOM with the function insertAdjacentHTML() in a loop for()... the function that performs this task is in a Promise() and its return…
-
0
votes2
answers73
viewsSum total of a loop
I’m trying to make a total sum of a "for" but it’s all too crazy or "zeroed"... <?php for ($i=0; $i < count($data); $i++) { $total_receitas_recebidas = 0; $total_receitas_a_receber = 0;…
-
0
votes0
answers54
viewsPerform the hook 'beforeUpdate' only once in Vuejs
I got a code pad inside the hook beforeUpdate() of the Vue instance, and it is running several times in a row. My question is: It’s normal to hook beforeUpdate() be called several times?? If not,…
-
0
votes1
answer207
viewsHow do I identify the amount that was repeated and the names repeated?
Make an algorithm in Portuguese that reads the name of up to 100 people and enter the number of names equal to "Jose da silva" and the number of names equal to "ana maria". The algorithm should not…
-
0
votes2
answers638
viewsWhile inside other While in Java
I am trying to do a while inside another while and after executing the code within the second while I ask if you want to continue or not, if yes, the program should loop from the first while. It…
-
0
votes2
answers119
viewsonBlur (Javascript) inside a Loop For PHP
I have the following Java code: <script type='text/javascript'> function Calc(){ var qnt = document.getElementById('qnt_saida').value; var vlr = document.getElementById('vl_unt_org').value;…
-
0
votes1
answer114
viewsDifficulty in While Loops and Foreach
I’ve been studying php for a little while so I didn’t properly understand the structure of the loops as while and foreach I would like someone to explain to me why this while displays nothing, and…
-
0
votes3
answers5118
viewsJava Tabulated Calculation, using Repeat Loops
I’m having trouble solving the following exercise: Display the tabulated results of any number. The user informs what value he wants. The tabulation should be performed from 0 to 10, using the loop…
-
0
votes0
answers146
viewsRead file and create loop
I have a txt file with several names in column: Nome 01 Nome 02 Nome 03... In the archives. js I need to create a loop so that each name is read and uploaded to a variable for the calculations to be…
-
0
votes3
answers3591
viewsHow to use "while not in" in Python?
I tried to loop with while to check if a condition was met. If the user enters 0, 1 or 2 the program should stop asking the user which number he will choose. If the user chooses a number other than…
-
0
votes2
answers1354
viewsSelect from cursor
I am trying to make a trial with the following mysql block: DECLARE done INT DEFAULT FALSE; DECLARE v_id INT; DECLARE R CURSOR FOR SELECT id ,nome FROM pessoa d DECLARE CONTINUE HANDLER FOR NOT…
-
0
votes1
answer49
viewsIf inside the Loop does not work properly
Good evening. I have the following function: function verificaOnOff(){ for(var i in tbModulos){ var mod = tbModulos[i]; $.get('http://'+ mod.ip +'/rele', function(data) { if (data == '1') {…
-
0
votes0
answers40
viewsRestart the while loop method
I have a script to generate a certain amount of random Cpfs in a text file. When executing the method that generates the random CPF within the while, the method is executed only once and always…
-
0
votes1
answer633
viewsParse txt file and return to another file - Python
Good night! There is a file with numbers, save in txt format, each number separated by space, with a list with about 50 values in each line of the txt file (and more than 10,000 lines in the file):…
-
0
votes3
answers1365
viewsCreating html elements in javascript looping
I am very new with javascript and when it comes to creating loopings I get totally lost, the code below is to create the elements with each click and number the id and the text, but I’m having…
-
0
votes1
answer65
viewsFixed values and values in javascript looping
The code below creates new input and send the values to textarea, as the number of input is undefined it was necessary to make a looping to catch the values through the name, it works normally if…
-
0
votes2
answers72
viewsShow first and last record of each date
I would like to search the database for all records according to the "DOCTOR" between two dates DATA_INICIAL and DATA_FINAL No repeat records of the day. CURRENT RESULT: BRUNO BARBOSAS 02/04/2018…
-
0
votes1
answer656
viewsHow to repeat a snippet of html using a repetition loop in php?
<div class="container"> <form method="POST" action='enviaMform.php'> <div class="form-group"> <label for="nomeHost">Host que pretende monitorar:</label> <input…
-
0
votes1
answer41
viewsDisplay only results that satisfy the condition within the loop
I’m building a little algorithm that runs through a ArrayList and compares the value found with a value typed by the user. But I want to print on the screen only the value that satisfies the…
-
0
votes0
answers82
viewsSave loop for data to database
Good morning I am developing a financial part where I fill out a certain form which is due date, full amount, discounted value, school year, percentage of the discount and amount of portion however…
-
0
votes1
answer89
viewsWhy don’t you get in the loop?
I’m storing student names and grades and trying to display name, grades and media. The problem is that the program is skipping the loop of notes and is only taking the name. #include <stdio.h>…
-
0
votes1
answer18
viewsShow post with include_once
I want to list all my posts from all my custom post type, so far I get list in index.php But the problem is that it only lists one post of each custom post type. My index.php loop <?php $args =…
-
0
votes1
answer133
viewsHow to declare null values in C
My problem is the next one I’m creating loop while which cannot receive values less than or equal to zero, and would also declare that it cannot receive empty values for the program force the user…
-
0
votes2
answers67
viewsHow to relate two lists, obtaining the value of one through the maximum of the other?
I’m stuck in an exercise asking for an X number of teams participating in a championship. In the later lines is typed the name of the team and its score. In the output, the team that made more…
-
0
votes1
answer34
viewsGo adding for values in the array
I created an array: var tagListArray = []; for(i = 0; i<resultados.item(i); i++){ tagListArray = ["valor1", "valor2"]; } console.log(tagListArray); That one resultados.item(i) me returns x…