A for loop is a control structure used by many programming languages to iterate over a range. It is a way of repeating statements a number of times until the loop ends. Depending on the language this may be over a range of integers, iterators, etc.

learn more…| top users | synonyms (1)

0
votes
0answers
12 views

WebdriverWait is showing TimeoutException

I am scraping FB marketplace and I am able to log in and navigate to the marketplace. However, my code frequently breaks when I run the following function. It has something to do with the "circle ...
-2
votes
0answers
40 views

How to speed up a for loop using Rcpp package

I have a data frame lvl with 5 columns and more than a million rows.The structure of the lvl is something like this:lvl <- tribble(~lvl_1, ~lvl_2, ~lvl_3, ~lvl_4, ~lvl_5,"a", NA, NA, NA, ...
-2
votes
4answers
53 views

How to access first letter of a word in a string which is inside an array?

I have an array which consists of one cell which holds a string.var myArray=["hopefully i will get an answer to this problem"]Trying to loop through the array itself isn't bearing any fruit as i ...
-3
votes
2answers
53 views

Why does not this code run?

In the code you need to take 100 straight-angle triangles and print the biggest triangle. What am I not doing right?import java.util.Scanner;public class rthji {/*** @param args*/...
2
votes
2answers
21 views

For statement nested in while statement not working

I am learning how to use while and for loops, and am having difficulty executing a for loop within a while loop. I am trying to recurse a simple procedure over a vector, and have the while loop set ...
0
votes
1answer
28 views

Loop with in a loop

Is it possible to index an array in a loop with in a loop (Matlab)? So I'm indexing a 3d matrix with 3 parameter:For instance:A(1,1,:)A(1,2,:)...A(1,9,:)then I want the code to jump to the ...
0
votes
2answers
49 views

Addition of every six consecutive numbers to give their sums

I want my program to add every six consecutive weights and display their sum and then calculate the sum of the next six weights and so on, and finally display the total as the addition of all the sums....
0
votes
0answers
13 views

Finding the best LCA model in poLCA R package

I am applying LCA analysis with PoLCA R package, but the analysis not resulted since three days (it did not find the best model yet) and occasionally it gives the following error: "ALERT: iterations ...
1
vote
1answer
20 views

Loop for pagination params in requests.get

I want to pars vacancies. And my goal is to pars vacancies just one companyimport requestsfrom tqdm import tqdm_notebookimport pandas as pdr=requests.get('https://api.hh.ru/vacancies?...
0
votes
4answers
34 views

How do you pick out certain values from a list based on their string values in Python?

I have a list of hyperlinks, with three types of links; htm, csv and pdf. And I would like to just pick out those that are csv. The list contains strings of the form: csv/damlbmp/...
-1
votes
2answers
25 views

How to reference variables from previous iterations of a loop?

The example here is a program in Python 3 that helps you memorize the digits of pi. I have tried using the var counter1 to show the current score, while counter2 is the score from the last round. ...
7
votes
7answers
266 views

Repeating elements in a vector with a for loop

I want to make a vector from 3:50 in R, looking like 3 4 4 5 6 6 7 8 8 .. 50 50 I want to use a for loop in a for loop but it's not doing wat I want.f <- c()for (i in 3:50) {for(j in 1:...
1
vote
3answers
64 views

Java for loop only storing last value

I have a for loop in java android and it runs perfectly but it only stores to the last item in the list it is looping through. Should I make user_id and lesson_id a list? I don't know where to go from ...
0
votes
1answer
32 views

Get the full file path with OpenFileDialog class

Using the OpenFileDialog.java class to create the file selection dialog, I did not find a way to get the full path of the selected file upon ok button click. I tried to use String currentPath and ...
2
votes
1answer
23 views

Trying to normalize data, but got undefined columns selected error in R

I have a dataset contains a variable nr.employed. Its numeric.I am normalizing it in using codemarkting_train_dim_deleted="","custAge","profession","marital","schooling","default","contact","...
2
votes
0answers
57 views

After using for loop in Python it only returns the last value of a csv file [on hold]

I'm trying to learn python since a few days ago.city_data={'Washington': 'http://stackoverflow.com/data/Washington-2016-Summary.csv','Chicago': 'http://stackoverflow.com/data/Chicago-2016-Summary.csv','NYC': 'http://stackoverflow.com/...
-1
votes
1answer
21 views

How to print database data into 4x4 format,just like we see on shopping websites?

I am doing this program in php.foreach ($rs_result as $value) {echo $value['name']; for($i=0;$i<4;$i++){for($j=0;$j<4;$j++){echo $value['name'];}echo "<br>";...
2
votes
5answers
64 views

How to create tuple with a loop in python

I want to create this tuple:a=(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5),(6,6,6),(7,7,7),(8,8,8),(9,9,9)I tried with thisa=1,1,1for i in range (2,10):a=a,(i,i,i)However it creates a tuple ...
-2
votes
0answers
23 views

How to create the for loop from c code to assembly

This is an assignment for my lab. We are suppose to translate this C code to assembly. I have trouble creating the for loop and this is what I got so far.__mainMOV R1, #-6MOV R2, #-18MOV R3, #...
0
votes
1answer
26 views

Using sets of variables to create another set of variables, or why not?

My dataset contains variables that measure the same thing at 5 different points. Let's call them X1, X2, X3, X4, X5 and Y1, Y2, Y3, Y4, Y5. This is just how the dataset is set up. I'm importing it as ...
3
votes
2answers
43 views

Permute matrix columns in parallel with R

I am trying to permute a matrix by columns using R.However, it is taking ages (the matrix is 68k x 32k integers).I would like to do it in parallel (since each column is permuted independently). How ...
1
vote
1answer
29 views

For-loop and coordinate duplicates in R

I would like to detect duplicate coordinates in a series:n <- 0for(ii in 1:11){for(jj in 1:11){w <- iix <- jjy <- iiz <- jjcoord1 <- c(w, x)coord2 <- c(y, z)...
0
votes
1answer
51 views

Why aren't iterations skipped in a for loop when the loop variable is incremented? [duplicate]

def loop():for i in range (0,9):passif i==3:i=i +3print(i)loop()Current output :012645678Expecting output:0126789Does this ...
2
votes
2answers
9k views

How to use looping in selenium webdriver java when every next generated element will have different names

UI ProjectThe scenario of the image above is the user can fill in all the details per partner, the user can add a maximum of 20 partners by clicking the add partner button, every time the user will ...
0
votes
1answer
40 views

R error in a loop simulating multiple graphs

I'm trying to construct a loop to plot 10 ROCs and to store AUC scores for 10 models by using R library ROCR. The loop I have created generates an error:Error in prediction(as.numeric(var_name[i]),...
-1
votes
2answers
26 views

Create Different number of columns each row in a table with PHP and MYSQL

I would like to make a table with different numbers of cols with PHP and with data from mysql.I got very stuck because i don't know how to do that with For and foreach. I am so lost. I have in my ...
0
votes
1answer
22 views

Swift 3 - distinguishing between “for loops”

I am trying to figure out the difference between the following:for i in A {andfor i in 0..<A.count {Don't they both just iterate through the array?
-1
votes
0answers
14 views

Automating a word report

Hi I'm trying to automate some parts of a report that I have to do daily, this is what I have and what I need, first I'm trying to do this with python, which is the language I'm trying to learn.We ...
-3
votes
1answer
52 views

Python for with assigment [on hold]

Can you please explain me and point me the docs about the usage of the for loop in the code below:myTask=Nonedef requires(self):return [self.myTask(date=self.date,file_date=...
0
votes
4answers
42 views

String of numbers can't start with zero. Other Solutions? [duplicate]

I have a string that only contains numbers, but the string can not start with a zero.The first thing I cam up with was this:let myNumber="0052";myNumber=myNumber.split('');for (let i=...
0
votes
2answers
31 views

R - Saving the values from a For loop in a vector or list

I'm trying to save each iteration of this for loop in a vector.for (i in 1:177) {a <- geomean(er1$CW[1:i])}Basically, I have a list of 177 values and I'd like the script to find the ...
0
votes
1answer
66 views

Java - Pair variable resets between consecutive for loop body executions

This is an excerpt from my project:import javafx.util.Pair;import org.w3c.dom.*;private Pair<Element, Integer> findBestAlbumElement(Element recording) {Pair<Element, Integer> ...
0
votes
2answers
21 views

Adding Unique Sheets From Range Values

I am attempting to write code that runs through column G, and adds a new sheet for every unique value with out creating duplicates; However from what I have so so it creates duplicates Public Sub ...
0
votes
2answers
28 views

Issue with using .extend on array inside a for loop

I have a set of checkboxes, and based on which items are selected, different upload fields will display. To facilitate this, I want to dynamically create an array with the classes I want to fetch.I ...
1
vote
1answer
216 views

Updating a chart while VBA is running

I'm trying to see visually what happens to a set of data in Excel each time I increment a driving variable by 1.The data is visualised in a chart and the increments are done via a for-next loop on ...
0
votes
2answers
71 views

VBA Union Not Working As Desired

My code is not working. It breaks on the uni.entirerow.delete line, with error 1004. That indicates that it is building the array, but I must be referencing something wrong? I originally was just ...
1
vote
1answer
81 views

For loop in VBA Code

NOTE: I was able to upload a link to a picture in the comments.I am using a for loop in an excel macro in an attempt to compile data. I have the following VBA code:Sub MoveData()'' MoveData ...
0
votes
2answers
57 views

For Next Loop in VBA running wrong number of times

I have some VBA which creates a summary report based on a worksheet in Excel. As part of this there is a For... Next loop which sometimes runs the correct number of times and sometimes runs one too ...
0
votes
1answer
35 views

How to Display key labels and values in Jekyll for loop data that has been grouped

I got the following to work:{% assign cars=site.data.inventory %}{% for item in cars %}{{item}}{% endfor %}The result looks like a jumble of key pairs.{"brand"=>"Toyota", "model"=>"...
0
votes
1answer
23 views

For loop refusing to step through

I have extreamly simple for loop, or so I thought, which is refusing to step through. Whenever I run th main code, this is an exsert, the code would just seem to not be running, I have narrowed it ...
1
vote
3answers
67 views

Creating a temporary variable in a for loop

I had a for loop designed to add 6 values to an arraylist.ArrayList<Integer> list=new ArrayList<Integer>();for (int i=list.size(); i < list.size() + 6; i++){list.add(2 * i);...
4
votes
2answers
115 views

Big-O analysis of for loop algorithm

I'm having trouble analyzing the following for loop algorithm:for (int i=1; i < n; i=i * C)for (int j=0; j < i; j++)Sum[i] +=j * Sum[i];I know that the first line has a ...
-1
votes
0answers
25 views

Use iterator in Javafx to remove current element [duplicate]

I want to iterate my folders list until I find the folder to rename.I used for that the answer in this topic : Iterating through a Collection, avoiding ConcurrentModificationException when removing ...
0
votes
1answer
37 views

Nested dimensions in macro array argument

I am providing a multi-dimensional array to a macro in Word. Each element is an array, and each array element has 2 values, the name of an image and a short description. The macro is:For i=LBound(...
0
votes
1answer
41 views

Optimizing loop for by using vectors python

I created following code:M=20000sample_all=np.load('sample.npy') sd=np.zeros(M)chi_arr=np.zeros((M,4))sigma_e=np.zeros((M,41632))mean_sigma=np.zeros(M)max_sigma=np.zeros(M)...
0
votes
2answers
41 views

Python3 For-Loop and If-Statement trouble

I just wrote some code which should go through each line of a file and should call another function if the number after the first word of the line is a 1.The file looks like this:Button0 1Button1 ...
-3
votes
1answer
53 views

two variable in for loop in python

My question is about for loops in python. When I use C, I use two variables in the same for loop like this:for (i=0, j=5; i<5, j>0; i++, j--)How can I create this for loop in python?
246
votes
14answers
72k views

Why does python use 'else' after for and while loops?

I understand how this construct works:for i in range(10):print(i)if i==9:print("Too big - I'm giving up!")break;else:print("Completed successfully")But I don't ...
0
votes
0answers
35 views

Complexity analysis of image filter C++

So I have coded a filter for an image in C++ using minimum spanning trees (MST), but my computer science theory is limited so I can't work out the complexity of my code.double nonLocalAtPixel(int ...
-2
votes
2answers
55 views

For loop calculates the Celsius equivalent to Fahrenheit Temperatures Java

I have a problem with this program. I get no compile errors, but when I run it didn’t display the decimal point for Celsius output.Here is my code:public class TempLoops {public static void ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,