C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Stuck in while loop

By : kavya h s
Date : November 21 2020, 11:01 PM
To fix the issue you can do I'm trying to make a dice tosser for my nephew so he can play boardgames without dice. i have got stuck in a while loop if even if i enter a condition that is true. I'm trying to get him to select which dice he wants to use but if he selects a wrong dice then it asks him to enter it again. my code is ... , Try This:
code :
``````    dice_select = int(input('Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12:  '))
while not (dice_select == 4 or dice_select == 6 or dice_select == 12):
dice_select = int(input('Sorry thats not quite right. Enter the amount of sides are on the dice you want to throw, either 4, 6, or 12:  '))
``````

Share :

## Using do while loop and while loop to write a program that will run random guessing game...i stuck at the do while loop

By : Nate Jahns
Date : March 29 2020, 07:55 AM
hop of those help? First of all the formula you are using to calculate the random number is wrong. Suppose that min is 10, and max is 12. Then the rand() % max could be, let's say, 10. Adding min (10), the number to guess would be 20 - far greater than max... It should be secret = rand() % (max-min +1) + min; (if your interval is [min, max]).
Now to your question - as far as I understood you want to know if the entered guess is a number. Here is what you can do:
code :
``````    while(1)
{
cin >> guess;

if(cin){
if (guess > max){
cout << "Too high!\n\n";
cin.clear();
cin.ignore();
continue;
}
else if (guess < min){
cout << "Too low!\n\n";
cin.clear();
cin.ignore();
continue;
}
else if(guess != secret){
deposit-=bet;
cout<< "Sorry, U lose RM "<< bet;
}
else if(guess == secret){
bet*=10;
deposit+=bet;
cout<< "\n\nCongratulation! U earn RM "<< bet;
}
break;
}
else
{

cin.clear();
cin.ignore();
cout << "Error! You did not enter a number!" << endl;
continue;
}
}
``````
``````    do{
cout<< "Wanna play again (y/n)? ";

cout<< "\nReally? Ok, try again! \n";

goto AA;

cout<< "\n\n\n"<< setw(80)<< setfill('+')<< "\n\n";
cout<< setw(30)<< "THX FOR PLAYING! UR CURRENT BALANCE IS RM "<< deposit<< "\n\n";
cout<< setfill('+')<< setw(80)<< "\n";
}
``````
``````cout << "Pls enter the min of secret number\n";
while (!(cin >> min) || min<=0){

cout << "Pls enter the min of secret number\n";
cin.clear();
cin.ignore();

}
``````

## Trying to write a validation loop in Xcode 7 (Swift 2) for an iOS mobile app - stuck on infinite loop

By : Prudhvi Gsv
Date : March 29 2020, 07:55 AM
it should still fix some issue I am attempting to create an app (iOS) where a random number generator is used to display an arithmetic problem. The random number generator will decide what operation the user will perform (multiplication, subtraction, addition) and which operands are used. The user can select the difficulty level by using a segmented control. , If you want to break the while loop only:
code :
``````     while newAnswer != correctAnswer {
feedback.text = "Try Again!"
i+=1
if i == 3 {
break
}
}
``````
``````if newAnswer != correctAnswer {
feedback.text = "Try Again!"
i+=1
if (i<3){
return
}
}
``````

## IE-Automation: Stuck with debuging only first instance of loop is done correctly, but loop does not break

By : M0rb1dD3v1l
Date : March 29 2020, 07:55 AM
I hope this helps . I notice you never reset the variable ActRw, which means you start copying to row 1 of the first worksheet you create, then the second worksheet you create you start your copying at the row after the one you finished the first sheet at.
So are you sure you aren't writing anything to the second sheet - or are you just writing it at row 100 or something?
code :
``````ActRw = 0
``````
``````Dim ActRw  As Long
``````

## While function stuck in loop, seems that half of loop doesn't execute

By : Monika Wanot
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Presumably Vote.find does its work asynchronously (and similarly for Vote.findOneAndUpdate). Your for and while loops do not. So delegationsLeft will never be anything but 1 during the course of your loop.
If you're interacting with asynchronous results, you can't use while (or for or do-while). Instead, you need to schedule the next "iteration" of the "loop" from within the asynchronous callback.

## iteration getting stuck in loop(infinite loop) while tracking image

By : Y. C.
Date : March 29 2020, 07:55 AM
Does that help I believe the issue is with your indentation. Currently it reads something like this:
code :
``````While True:
for some_stuff in stuff:
if (conf < 60):
add a timestamp record to attendence.loc
else:
set some Id

if (conf > 75):
write an image file

# This runs on every while loop
cv2.imshow('im',im)
if (cv2.waitKey(1) == ord('q')):
break

# This runs once while is no longer True (after pressing `q`)
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
Hour,Minute,Second = timeStamp.split(":")
fileName = "Attendence\Attendence_" +date+"_"+ Hour+"-"+Minute+"-"+Second+".csv"
attendence.to_csv(fileName,index=False)
``````
``````def write_file(attendance):
ts = time.time()
date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d')
timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S')
Hour,Minute,Second = timeStamp.split(":")
fileName = "Attendence\Attendence_" +date+"_"+ Hour+"-"+Minute+"-"+Second+".csv"
attendence.to_csv(fileName,index=False)

While True:
for some_stuff in stuff:
if (conf < 60):
add a timestamp record to attendence.loc
write_file(attendence)
else:
set some Id

if (conf > 75):
write an image file

# This runs on every while loop
cv2.imshow('im',im)
if (cv2.waitKey(1) == ord('q')):
break
``````