Top "For-loop" questions

A for loop is a control structure used by many programming languages to iterate over a range.

Add characters to a string in Javascript

I need to add in a For Loop characters to an empty string. I know that you can use the …

javascript string for-loop
Java 8 Iterable.forEach() vs foreach loop

Which of the following is better practice in Java 8? Java 8: joins.forEach(join -> mIrc.join(mSession, join)); Java 7: …

java for-loop java-8 java-stream
While loop in batch

Here is what I want, inside the BACKUPDIR, I want to execute cscript /nologo c:\deletefile.vbs %BACKUPDIR% until number …

windows batch-file for-loop while-loop
Get loop count inside a Python FOR loop

In a Python for loop that iterates over a list we can write: for item in list: print item and …

python for-loop
Breaking out of a for loop in Java

In my code I have a for loop that iterates through a method of code until it meets the for …

java loops for-loop break
How to check if all elements of a list matches a condition?

I have a list consisting of like 20000 lists. I use each list's 3rd element as a flag. I want to …

python list for-loop while-loop
How do I fix "for loop initial declaration used outside C99 mode" GCC error?

I'm trying to solve the 3n+1 problem and I have a for loop that looks like this: for(int i = …

c gcc for-loop
How to loop through key/value object in Javascript?

var user = {}; now I want to create a setUsers() method that takes a key/value pair object and initializes the …

javascript loops for-loop iteration key-value
Python loop counter in a for loop

In my example code below, is the counter = 0 really required, or is there a better, more Python, way to get …

loops for-loop python
Difference between pre-increment and post-increment in a loop?

Is there a difference in ++i and i++ in a for loop? Is it simply a syntax thing?

for-loop language-agnostic post-increment pre-increment