tagged [loops]

Loop backwards using indices

Loop backwards using indices I am trying to loop from 100 to 0. How do I do this in Python? `for i in range (100,0)` doesn't work. --- `range`[Why are slice and range upper-bound exclusive?](https://s...

4 Jan at 04:22

Traverse a list in reverse order in Python

Traverse a list in reverse order in Python How do I traverse a list in reverse order in Python? So I can start from `collection[len(collection)-1]` and end in `collection[0]`. I also want to be able t...

6 Sep at 10:26

Is the condition in a for loop evaluated each iteration?

Is the condition in a for loop evaluated each iteration? When you do stuff like: ``` for (int i = 0; i

11 Aug at 16:4

Two counters in a for loop for C#

Two counters in a for loop for C# Hi couldn't find it for C#, I am trying something like that ``` for (int j = mediumNum; j

23 May at 21:12

Accessing the index in 'for' loops

Accessing the index in 'for' loops How do I access the index while iterating over a sequence with a `for` loop? Desired output:

8 Aug at 00:51

Continue in nested while loops

Continue in nested while loops In this code sample, is there any way to continue on the outer loop from the catch block?

15 Jul at 19:20

How to break nested loops in JavaScript?

How to break nested loops in JavaScript? I tried this: ``` for(i = 0; i `SyntaxError`: missing `;` before statement So, how would I break a nested loop in JavaScript?

2 Mar at 13:43

Can I use break to exit multiple nested 'for' loops?

Can I use break to exit multiple nested 'for' loops? Is it possible to use the `break` function to exit several nested `for` loops? If so, how would you go about doing this? Can you also control how m...

13 Jan at 18:33

How do I loop through or enumerate a JavaScript object?

How do I loop through or enumerate a JavaScript object? I have a JavaScript object like the following: How do I loop through all of `p`'s elements (`p1`, `p2`, `p3`...) and get their keys and values?

8 May at 17:29

How to loop over a Class attributes in Java?

How to loop over a Class attributes in Java? How can I loop over a class attributes in java dynamically. For eg : is this possible in Java?

7 Feb at 08:34

Why is foreach loop Read-Only in C#

Why is foreach loop Read-Only in C# Why is foreach loop a read only? I mean you can fetch the data but can't increase++ or decrease--. Any reason behind it? Yes I am a beginner :) Exmaple:

23 Oct at 15:55

Is it possible to implement a Python for range loop without an iterator variable?

Is it possible to implement a Python for range loop without an iterator variable? Is it possible to do following without the `i`? If you just want to do something N amount of times and don't need the ...

29 Jul at 13:50

How to loop through key/value object in Javascript?

How to loop through key/value object in Javascript? now I want to create a `setUsers()` method that takes a key/value pair object and initializes the `user` variable. where data is like:

How do I apply the for-each loop to every character in a String?

How do I apply the for-each loop to every character in a String? So I want to iterate for each character in a string. So I thought: but I get a compiler error: How can I do this?

23 Feb at 22:49

Iterate through adjacent pairs of items in a Python list

Iterate through adjacent pairs of items in a Python list Is it possible to iterate a list in the following way in Python (treat this code as pseudocode)? And it should produce

17 Feb at 14:25

How to find the most recent file in a directory using .NET, and without looping?

How to find the most recent file in a directory using .NET, and without looping? I need to find the most recently modified file in a directory. I know I can loop through every file in a folder and com...

6 Nov at 00:37

Iterating over all the keys of a map

Iterating over all the keys of a map Is there a way to get a list of all the keys in a Go language map? The number of elements is given by `len()`, but if I have a map like: How do I iterate over all ...

19 Jul at 23:5

Iterate through object properties

Iterate through object properties How does the variable `propt` represent the properties of the object? It's not a built-in method or property. Why does it come up with every property in the object?

13 Mar at 10:58

Is there a difference between "pass" and "continue" in a for loop in Python?

Is there a difference between "pass" and "continue" in a for loop in Python? Is there any significant difference between the two Python keywords `continue` and `pass` like in the examples and I should...

21 Dec at 14:23

Loop through childNodes

Loop through childNodes I'm trying to loop through childNodes like this: However, it output `Uncaught TypeError: undefined is not a function` due to `forEach` function. I also try to use `children` in...

16 Jul at 08:23

How to loop through an associative array and get the key?

How to loop through an associative array and get the key? My associative array: Using the following code, `$v` is filled with `$arr`'s values How do I get `$arr`'s keys instead?

5 Nov at 13:56

How can INSERT INTO a table 300 times within a loop in SQL?

How can INSERT INTO a table 300 times within a loop in SQL? I would like to insert a value retrieved from a counter in SQL and repeat it 300 times. Something like: How can I achieve this? Thanks

21 Feb at 10:12

C# loop - break vs. continue

C# loop - break vs. continue In a C# (feel free to answer for other languages) loop, what's the difference between `break` and `continue` as a means to leave the structure of the loop, and go to the n...

7 Jul at 20:59

How to loop through array in jQuery?

How to loop through array in jQuery? I am trying to loop through an array. I have the following code: Am trying to get all the data out of the array. Can some one lead me in the right path please?

How to break out of jQuery each loop?

How to break out of jQuery each loop? How do I break out of a jQuery [each](https://api.jquery.com/each/) loop? I have tried: in the loop but this did not work. Any ideas? --- ## Update 9/5/2020 I put...

29 Sep at 05:44