Top "While-loop" questions

A while loop is a control structure used in many programming languages to continuously execute a set of instructions as long as a particular condition is met.

Else clause on Python while statement

I've noticed the following code is legal in Python. My question is why? Is there a specific reason? n = 5 while …

python syntax while-loop if-statement
How to break out of a loop in Bash?

I want to write a Bash script to process text, which might require a while loop. For example, a while …

bash shell while-loop
How to populate HTML dropdown list with values from database

as part of a HTML form I am creating I would like to have a dropdown list which will list …

php sql while-loop
A variable modified inside a while loop is not remembered

In the following program, if I set the variable $foo to the value 1 inside the first if statement, it works …

bash while-loop scope sh
How to kill a while loop with a keystroke?

I am reading serial data and writing to a csv file using a while loop. I want the user to …

python while-loop break
Are "while(true)" loops so bad?

I've been programming in Java for several years now, but I just recently returned to school to get a formal …

java while-loop do-while
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
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
Declaring variables inside or outside of a loop

Why does the following work fine? String str; while (condition) { str = calculateStr(); ..... } But this one is said to be dangerous/…

java optimization while-loop
How to break out of while loop in Python?

I have to make this game for my comp class, and I can't figure out how how break out of …

python while-loop break