tagged [for-loop]
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 ...
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:
- Modified
- 17 Sep at 07:0
How do I put two increment statements in a C++ 'for' loop?
How do I put two increment statements in a C++ 'for' loop? I would like to increment two variables in a `for`-loop condition instead of one. So something like: What is the syntax for this?
- Modified
- 17 Apr at 13:3
What is the difference between for and foreach?
What is the difference between for and foreach? What is the major difference between `for` and `foreach` loops? In which scenarios can we use `for` and not `foreach` and vice versa. Would it be possib...
List append() in for loop raises exception: 'NoneType' object has no attribute 'append'
List append() in for loop raises exception: 'NoneType' object has no attribute 'append' In Python, trying to do the most basic append function to a list with a loop: Not sure what I am missing here: r...
Performance difference for control structures 'for' and 'foreach' in C#
Performance difference for control structures 'for' and 'foreach' in C# Which code snippet will give better performance? The below code segments were written in C#. 1. ``` for(int tempCount=0;tempCoun...
- Modified
- 20 Jan at 23:8
What does the colon (:) operator do?
What does the colon (:) operator do? Apparently a colon is used in multiple ways in Java. Would anyone mind explaining what it does? For instance here: ``` String cardString = ""; for (PlayingCard c :...
How to loop through each row of dataFrame in pyspark
How to loop through each row of dataFrame in pyspark E.g The above statement prints theentire table on terminal. But I want to access each row in that table using `for` or `while` to perform further c...
- Modified
- 16 Dec at 17:36
Use of "for (;;)" in a C# application?
Use of "for (;;)" in a C# application? I've been looking through some sample source code for an application I use and I came across this line: It looks like this is to create an infinite loop, but I'm...
Python - How to concatenate to a string in a for loop?
Python - How to concatenate to a string in a for loop? I need to "concatenate to a string in a for loop". To explain, I have this list: And inside a for loop I need to end with this: Can you give me a...
- Modified
- 23 Nov at 21:55
Creating for loop until list.length
Creating for loop until list.length I'm reading about for loops right now, and I am curious if it's possible to do a for loop in Python like in Java. Is it even possible to do something like ``` for (...
C++ Loop through Map
C++ Loop through Map I want to iterate through each element in the `map` without knowing any of its string-int values or keys. What I have so far:
- Modified
- 6 Sep at 20:38
Exiting out of a FOR loop in a batch file?
Exiting out of a FOR loop in a batch file? Why does this batch file never break out of the loop? Shouldn't the `Goto :EOF` break out of the loop? ### Edit: I guess I should've asked more explicitly......
- Modified
- 20 Jun at 09:12
Is it possible to declare two variables of different types in a for loop?
Is it possible to declare two variables of different types in a for loop? Is it possible to declare two variables of different types in the initialization body of a for loop in C++? For example: defin...
- Modified
- 22 Apr at 00:53
"for loop" with two variables?
"for loop" with two variables? How can I include two variables in the same `for` loop?
While, Do While, For loops in Assembly Language (emu8086)
While, Do While, For loops in Assembly Language (emu8086) I want to convert simple loops in high-level languages into assembly language (for emu8086) say, I have this code: ``` for(int x = 0; x
- Modified
- 20 Aug at 03:16
Never seen before C++ for loop
Never seen before C++ for loop I was converting a C++ algorithm to C#. I came across this for loop: It gives no error in C++, but it does in C# (cannot convert int to bool). I really can't figure out ...
How can I use break or continue within for loop in Twig template?
How can I use break or continue within for loop in Twig template? I try to use a simple loop, in my real code this loop is more complex, and I need to `break` this iteration like: How can I use behavi...
Breaking/exit nested for in vb.net
Breaking/exit nested for in vb.net How do I get out of nested for or loop in vb.net? I tried using exit for but it jumped or breaked only one for loop only. How can I make it for the following:
- Modified
- 25 Feb at 11:3
Get current index from foreach loop
Get current index from foreach loop Using C# and Silverlight How do I get the index of the current item in the list? Code: ``` IEnumerable list = DataGridDetail.ItemsSource as IEnumerable; List lstFil...
- Modified
- 27 Apr at 08:9
Do an action only if a condition is met in all iterations of a loop
Do an action only if a condition is met in all iterations of a loop Is there a way to only trigger an action when a condition is met in iterations of a `for` loop? Example: This is what I tried, but i...
How to efficiently remove all null elements from a ArrayList or String Array?
How to efficiently remove all null elements from a ArrayList or String Array? I try with a loop like that But it isn't nice. Can anyone suggest me a better solution? --- Some useful benchmarks to make...
- Modified
- 15 Dec at 20:43
While loop in batch
While loop in batch Here is what I want, inside the `BACKUPDIR`, I want to execute `cscript /nologo c:\deletefile.vbs %BACKUPDIR%` until number of files inside the folder is greater than 21(`countfile...
- Modified
- 13 Jan at 09:0