Top "For-loop" questions

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

Null check in an enhanced for loop

What is the best way to guard against null in a for loop in Java? This seems ugly : if (someList != …

java syntax loops for-loop
Reverse a string without using reversed() or [::-1]?

I came across a strange Codecademy exercise that required a function that would take a string as input and return …

python string function for-loop reverse
For-loop vs while loop in R

I have noticed a curious thing whilst working in R. When I have a simple program that computes squares from 1 …

r for-loop floating-point while-loop
Decrementing for loops

I want to have a for loop like so: for counter in range(10,0): print counter, and the output should be 10 9 8 7 6 5 4 3 2 1

python for-loop decrement
For Loop on Lua

My assignment is how to do a for loop. I have figured it out in terms of numbers but cannot …

loops for-loop lua
Python for and if on one line

I have a issue with python. I make a simple list: >>> my_list = ["one","two","three"] I …

python python-2.7 for-loop if-statement list-comprehension
TypeError: 'list' object cannot be interpreted as an integer

The playSound function is taking a list of integers, and is going to play a sound for every different number. …

python list for-loop typeerror
Loop through a comma-separated shell variable

Suppose I have a Unix shell variable as below variable=abc,def,ghij I want to extract all the values (…

shell loops unix for-loop cut
How do you Make A Repeat-Until Loop in C++?

How do you Make A Repeat-Until Loop in C++? As opposed to a standard While or For loop. I need …

c++ loops for-loop while-loop